Submission

Status:
PPPPPPPPPP

Score: 100

User: Sense143

Problemset: เรือสำราญ

Language: cpp

Time: 0.002 second

Submitted On: 2024-09-25 14:25:35

#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int main(){
    ios::sync_with_stdio(false); cin.tie(0);
    map<int,int> time;
    int n,m; cin >> n >> m;
    int con = m;
    int k; cin >> k;
    while(m <= n){
        time[m] = 1;
        m += con;
    }
    for(int i=0;i<k;i++){
        int u,v; cin >> u >> v;
        int temp;
        if(u%con == 0){
            temp = u;
        }
        else{
            temp = (u/con)+1;
            temp *= con;
        }
        int temp2;
        if(v%con == 0){
            temp2 = v;
        }
        else{
            temp2 = (v/con);
            temp2 *= con;
        }
        for(int j=temp;j<=temp2;j+=con){
            time[j]++;
        }
    }
    vector<int> ans;
    int cnt = 0;
    for(int i=con;i<=n;i+=con){
        if(time[i] == 1){
            cnt++;
            ans.push_back(i);
        }
    }
    if(cnt == 0){
        cout << "no" << endl;
        return 0;
    }
    cout << cnt << endl;
    for(auto e:ans){
        cout << e << endl;
    }
}