#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];
vector<pair<LL,LL>>vec;
struct node{
node *l,*r;
LL sum = 0;
int lazy = 0;
node():l(NULL),r(NULL){};
};
void push(node * &v,LL tl,LL tr){
if(v==NULL||!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){
push(v,tl,tr);
if(tl>r||tr<l)
return ;
if(v==NULL) v = new node();
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==NULL?0:v->l->sum)+(v->r==NULL?0:v->r->sum);
}
node *root;
int main(){
//freopen("out.txt","w",stdout);
LL n,a,b,Len;
scanf("%lld%lld%lld",&n,&a,&b);
if(log(a)+log(b)>=log(LLONG_MAX))
Len = LINF;
else
Len = a*b;
bool q = 0;
set<LL>st;
LL ans = 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].F<=p[i].S)
//ans += p[i].S-p[i].F+1;
for(int j=p[i].F;j<=p[i].S;j++)
st.insert(j);
else {
//ans += Len-p[i].F;
for(int j=p[i].F;j<=Len-1;j++)
st.insert(j);
for(int j=0;j<=p[i].S;j++)
st.insert(j);
//ans += p[i].S+1;
}
if(p[i].S>=p[i].F)
vec.push_back({p[i].F,p[i].S});
else
vec.push_back({p[i].F,Len-1}),vec.push_back({0,p[i].S});
}
// sort(vec.begin(),vec.end());
// LL l = 0,r = -1,ans = 0;
// vec.push_back({LINF,LINF});
// for(int i=0;i<vec.size();i++){
// if(vec[i].F>r)
// ans += r-l+1,l = vec[i].F,r = vec[i].S;
// else
// r = vec[i].S;
// }
printf("%lld\n",st.size());
}
Compilation message
strange_device.cpp: In function 'int main()':
strange_device.cpp:124:16: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'std::set<long long int>::size_type' {aka 'long unsigned int'} [-Wformat=]
124 | printf("%lld\n",st.size());
| ~~~^ ~~~~~~~~~
| | |
| | std::set<long long int>::size_type {aka long unsigned int}
| long long int
| %ld
strange_device.cpp:81:8: warning: unused variable 'ans' [-Wunused-variable]
81 | LL ans = 0;
| ^~~
strange_device.cpp:72:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
72 | scanf("%lld%lld%lld",&n,&a,&b);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
strange_device.cpp:84:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
84 | scanf("%lld%lld",&p[i].F,&p[i].S);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
43 ms |
9576 KB |
Output is correct |
3 |
Correct |
67 ms |
13736 KB |
Output is correct |
4 |
Incorrect |
3 ms |
844 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
3613 ms |
524292 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
328 KB |
Output is correct |
2 |
Correct |
109 ms |
24192 KB |
Output is correct |
3 |
Correct |
107 ms |
24132 KB |
Output is correct |
4 |
Correct |
105 ms |
23108 KB |
Output is correct |
5 |
Execution timed out |
5048 ms |
46992 KB |
Time limit exceeded |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
705 ms |
78664 KB |
Output is correct |
3 |
Runtime error |
3706 ms |
524292 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 |
705 ms |
78664 KB |
Output is correct |
3 |
Runtime error |
3706 ms |
524292 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 |
705 ms |
78664 KB |
Output is correct |
3 |
Runtime error |
3706 ms |
524292 KB |
Execution killed with signal 9 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Runtime error |
2822 ms |
524292 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
43 ms |
9576 KB |
Output is correct |
3 |
Correct |
67 ms |
13736 KB |
Output is correct |
4 |
Incorrect |
3 ms |
844 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |