Submission #198256

#TimeUsernameProblemLanguageResultExecution timeMemory
198256AMO5Strange Device (APIO19_strange_device)C++98
10 / 100
5123 ms524288 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair < ll ,ll> pll; ll n,a,b; map < pll , ll >vis; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> a >> b; ll le,ri, ans = 0; bool all = 0; for(ll i = 0; i < n; i++){ cin >> le >> ri; if(ri-le+1==a*b){ all = 1; } for(ll j = le; j <= ri&&!all; j++){ ll t = j; ll x = (t+(t/b))%a; ll y = t%b; if(!vis[{x,y}]){ ans++; } vis[{x,y}]++; } } if(all)ans=a*b; cout << ans << endl; }
#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...