Submission #403345

#TimeUsernameProblemLanguageResultExecution timeMemory
403345HazemStrange Device (APIO19_strange_device)C++14
10 / 100
1680 ms524292 KiB
#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 = 1e18; 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); if(log(a)+log(b)>log(LLONG_MAX)) Len = LINF; else 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 (stderr)

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:80:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   80 |         scanf("%lld%lld",&p[i].F,&p[i].S);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...