#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define F first
#define S second
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>
const int N = 1e6+10;
const int M = 200;
const LL INF = 1e9;
const LL LINF = 2e18;
const LL MOD = 1e9+7;
const double PI = 3.141592653589793;
pair<LL,LL>p[N];
struct node{
node *l,*r;
LL sum = 0,lazy = 0;
node():l(NULL),r(NULL){};
};
void push(node * &v,LL tl,LL tr){
if(!v->lazy)return ;
v->sum = tr-tl+1;
if(tl!=tr){
if(v->l==NULL)v->l = new node();
if(v->r==NULL)v->r = new node();
v->l->lazy = 1;
v->r->lazy = 1;
}
v->lazy = 0;
}
void update(node * &v,LL tl,LL tr,LL l,LL r){
if(v==NULL)
v = new node();
push(v,tl,tr);
if(tl>r||tr<l)
return ;
if(tl>=l&&tr<=r){
v->lazy = 1;
push(v,tl,tr);
return ;
}
LL mid = (tl+tr)/2;
update(v->l,tl,mid,l,r);
update(v->r,mid+1,tr,l,r);
v->sum = v->l->sum+v->r->sum;
}
node *root;
int main(){
//freopen("out.txt","w",stdout);
LL n,a,b,Len;
scanf("%lld%lld%lld",&n,&a,&b);
Len = a*b;
bool q = 0;
for(int i=1;i<=n;i++){
scanf("%lld%lld",&p[i].F,&p[i].S);
q |= p[i].S-p[i].F+1>=Len;
p[i].F %= Len;p[i].S %= Len;
if(p[i].S>=p[i].F)
update(root,0,LINF,p[i].F,p[i].S);
else
update(root,0,LINF,p[i].F,Len-1),update(root,0,LINF,0,p[i].S);
}
printf("%lld\n",q?Len:root->sum);
}
Compilation message
strange_device.cpp: In function 'int main()':
strange_device.cpp:71:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
71 | scanf("%lld%lld%lld",&n,&a,&b);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:78:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
78 | scanf("%lld%lld",&p[i].F,&p[i].S);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
24 ms |
6472 KB |
Output is correct |
3 |
Correct |
26 ms |
8116 KB |
Output is correct |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
5 ms |
2076 KB |
Output is correct |
3 |
Correct |
5 ms |
2124 KB |
Output is correct |
4 |
Correct |
5 ms |
1996 KB |
Output is correct |
5 |
Correct |
1254 ms |
15972 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1637 ms |
109960 KB |
Output is correct |
3 |
Runtime error |
945 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1637 ms |
109960 KB |
Output is correct |
3 |
Runtime error |
945 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1637 ms |
109960 KB |
Output is correct |
3 |
Runtime error |
945 ms |
524288 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
298 ms |
117208 KB |
Output is correct |
3 |
Correct |
496 ms |
285116 KB |
Output is correct |
4 |
Runtime error |
859 ms |
524292 KB |
Execution killed with signal 9 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
24 ms |
6472 KB |
Output is correct |
3 |
Correct |
26 ms |
8116 KB |
Output is correct |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |