Submission

Status:
PPP----PPP

Score: 60

User: Winzzwz

Problemset: เรือสำราญ

Language: cpp

Time: 0.011 second

Submitted On: 2024-11-13 14:59:39

#include <bits/stdc++.h>
using namespace std;
int k,t,n,s = 0, cnt;
unordered_map <int,bool> mark;
int main()
{
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> k >> t;
    cin >> n;
    cnt = t;
    s = k/t;
    while (n--) {
        int u,v;
        cin >> u >> v;
        for (int i = u; i <= v; i++) {
            if (i%t == 0) {s--; mark[i] = true;}
        }
    }
    if (s <= 0) {cout << "no"; exit(0);}
    cout << s << "\n";
    while (true) {
        if (cnt > k) break;
        if (!mark[cnt]) cout << cnt << "\n";
        cnt += t;
    }
    return 0;
}