#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int,int>
#define fr first
#define sc second
using namespace std;
vector<pii> intervals;
set<pii> uniqe;
signed main() {
int n, a, b; cin >> n >> a >> b;
for (int i = 0; i < n; i++) {
int x, y; cin >> x >> y;
intervals.pb({x, y});
}
for (int i = 0; i < n; i++) {
auto cur = intervals[i];
for (int j = cur.fr; j <= cur.sc; j++) {
int x = (j + j/b) % a;
int y = j % b;
uniqe.insert({x, y});
}
}
cout << uniqe.size() << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
43 ms |
12616 KB |
Output is correct |
3 |
Correct |
63 ms |
18156 KB |
Output is correct |
4 |
Correct |
2 ms |
852 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
424 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
1188 KB |
Output is correct |
10 |
Correct |
1 ms |
296 KB |
Output is correct |
11 |
Correct |
1 ms |
300 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
300 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
32 ms |
6980 KB |
Output is correct |
16 |
Correct |
28 ms |
6984 KB |
Output is correct |
17 |
Correct |
120 ms |
8504 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
2144 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
103 ms |
32188 KB |
Output is correct |
3 |
Correct |
126 ms |
32036 KB |
Output is correct |
4 |
Correct |
113 ms |
30624 KB |
Output is correct |
5 |
Execution timed out |
5026 ms |
78224 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1146 ms |
78564 KB |
Output is correct |
3 |
Runtime error |
2254 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1146 ms |
78564 KB |
Output is correct |
3 |
Runtime error |
2254 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1146 ms |
78564 KB |
Output is correct |
3 |
Runtime error |
2254 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1317 ms |
524288 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
43 ms |
12616 KB |
Output is correct |
3 |
Correct |
63 ms |
18156 KB |
Output is correct |
4 |
Correct |
2 ms |
852 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
424 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
7 ms |
1188 KB |
Output is correct |
10 |
Correct |
1 ms |
296 KB |
Output is correct |
11 |
Correct |
1 ms |
300 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
300 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
32 ms |
6980 KB |
Output is correct |
16 |
Correct |
28 ms |
6984 KB |
Output is correct |
17 |
Correct |
120 ms |
8504 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
1 ms |
212 KB |
Output is correct |
20 |
Runtime error |
2144 ms |
524288 KB |
Execution killed with signal 9 |
21 |
Halted |
0 ms |
0 KB |
- |