#include<bits/stdc++.h>
#define ll long long
#define fi first
#define sec second
#define pb push_back
#define pqueue priority_queue
#define int long long
#define pii pair<int,int>
#define supercepat ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
using namespace std;
int tc,ans=0,n,a,b;
int in1,in2;
int lp;
map<pair<int,int>,int> freq;
void solve(int l,int r){
int x,y;
for(int i=l;i<=r;i++){
x=((i+(i/b))%a);
y=i%b;
if(freq[{x,y}]==0) ans++;
freq[{x,y}]++;
}
}
main(){
supercepat;
cin>>n>>a>>b;
lp=a*b;
// if(n==1){
// cin>>in1>>in2;
// if(a==b+1) cout<<min(in2-in1+1,b)<<endl;
// else cout<<min(in2-in1+1,lp)<<endl;
// }
// else{
for(int i=1;i<=n;i++){
cin>>in1>>in2;
solve(in1,in2);
}
cout<<ans<<endl;
// }
}
Compilation message
strange_device.cpp:24:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
24 | main(){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
52 ms |
12612 KB |
Output is correct |
3 |
Correct |
77 ms |
18264 KB |
Output is correct |
4 |
Correct |
3 ms |
836 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 |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
316 KB |
Output is correct |
9 |
Correct |
10 ms |
1160 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
56 ms |
6948 KB |
Output is correct |
16 |
Correct |
30 ms |
7016 KB |
Output is correct |
17 |
Correct |
52 ms |
9328 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
4404 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 |
165 ms |
32220 KB |
Output is correct |
3 |
Correct |
205 ms |
32020 KB |
Output is correct |
4 |
Correct |
148 ms |
30628 KB |
Output is correct |
5 |
Execution timed out |
5104 ms |
62520 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 |
469 ms |
74072 KB |
Output is correct |
3 |
Runtime error |
2168 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 |
469 ms |
74072 KB |
Output is correct |
3 |
Runtime error |
2168 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 |
469 ms |
74072 KB |
Output is correct |
3 |
Runtime error |
2168 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 |
1790 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 |
52 ms |
12612 KB |
Output is correct |
3 |
Correct |
77 ms |
18264 KB |
Output is correct |
4 |
Correct |
3 ms |
836 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 |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
316 KB |
Output is correct |
9 |
Correct |
10 ms |
1160 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
56 ms |
6948 KB |
Output is correct |
16 |
Correct |
30 ms |
7016 KB |
Output is correct |
17 |
Correct |
52 ms |
9328 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Runtime error |
4404 ms |
524288 KB |
Execution killed with signal 9 |
21 |
Halted |
0 ms |
0 KB |
- |