Submission
Status:
PPPPPPPPPP
Score: 100
User: Monasm
Problemset: เรือสำราญ
Language: cpp
Time: 0.271 second
Submitted On: 2024-09-25 19:29:57
#include <bits/stdc++.h>
using namespace std;
int main() {
int k, t, n;
cin >> k >> t >> n;
vector<int> a;
for (int i = t; i <= k; i += t) {
a.push_back(i);
}
set<int> e;
for (int i = 0; i < n; i++) {
int u, v;cin >> u >> v;
for (int j = u; j <= v; j++) {
e.insert(j);
}
}
vector<int> ans;
for (auto i : a) {
if (e.find(i) == e.end()) {
ans.push_back(i);
}
}
if (ans.empty()) {
cout << "no" << endl;
} else {
cout << ans.size() << endl;
for (auto i : ans) {
cout << i << endl;
}
}
return 0;
}