#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fi first
#define se second
#define pb push_back
#define TC int t; cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
//*AC BERSAMA ALLAH FORTIS FORTUNA ADIUVAT
//# nyampah
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,a,b;
cin>>n>>a>>b;
set<pair<ll,ll> > sp, lr;
for(int i=0;i<n;i++){
ll l,r; cin>>l>>r;
if(lr.empty()){
lr.insert(make_pair(l*-1,r));
}
else{
pair<ll,ll> tmp=*lr.lower_bound(make_pair(-1*l,r));
if(l>tmp.se || r<tmp.fi*-1){ //diluar
lr.insert(make_pair(-1*l,r));
}
else if(l>=tmp.fi*-1 && r<=tmp.se){
continue;
}
else{
cout<<"C \n";
lr.erase(tmp);
if(l>tmp.fi*-1) l=tmp.fi*-1;
if(r<tmp.se) r=tmp.se;
lr.insert(make_pair(l*-1,r));
}
}
}
for(auto i : lr){
pair<ll,ll> tmp=i;
i.fi*=-1;
for(int j=i.fi;j<=i.se;j++){
sp.insert(make_pair(((j+j/b)%a),(j%b)));
}
}
cout<<sp.size();
return 0;
}
Compilation message
strange_device.cpp: In function 'int main()':
strange_device.cpp:43:21: warning: variable 'tmp' set but not used [-Wunused-but-set-variable]
43 | pair<ll,ll> tmp=i;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
5064 ms |
405660 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
2438 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 |
Execution timed out |
5047 ms |
60652 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
5058 ms |
140140 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
5058 ms |
140140 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
5058 ms |
140140 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1152 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 |
Execution timed out |
5064 ms |
405660 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |