Submission #243630

#TimeUsernameProblemLanguageResultExecution timeMemory
243630uacoder123Strange Device (APIO19_strange_device)C++14
0 / 100
522 ms16932 KiB
#include <bits/stdc++.h> using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef long long int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); lli test=1; for(;test>0;--test) { lli n,a,b,g,p,f,s,cl,cr,ans=0,ch=1; cin>>n>>a>>b; g=__gcd(a,b+1); g=a/g; if(1.0*g*b>1000000000000000000) p=1000000000500000000; else p=g*b; vector<ii> v; for(lli i=0;i<n;++i) { cin>>f>>s; if(f-s+1>=p) { ch=0; } f%=p; s%=p; if(f<=s) v.pb(mp(f,s)); else { v.pb(mp(0,s)); v.pb(mp(f,p-1)); } } if(ch==0) { cout<<p<<endl; exit(0); } sort(all(v)); v.pb(mp(p,p)); cl=0; cr=-1; ans=0; for(lli i=0;i<v.size();++i) { if(v[i].F<=cr&&v[i].S>=cr) { cr=v[i].S; } else { ans+=cr-cl+1; cl=v[i].F; cr=v[i].S; } } cout<<ans<<endl; } return(0); }

Compilation message (stderr)

strange_device.cpp: In function 'int main()':
strange_device.cpp:61:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(lli i=0;i<v.size();++i)
                 ~^~~~~~~~~
#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...