Submission #1058088

#TimeUsernameProblemLanguageResultExecution timeMemory
1058088kachim2Circle Passing (EGOI24_circlepassing)C++17
56 / 100
210 ms33316 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int n, m, q, pbm; cin >> n >> m >> q; set<int> v; auto pos = [n](int x){ return ((x)+2*n)%(2*n); }; for(int i = 0; i < m; i++){ int x; cin >> x; int y = pos(x+n); v.insert(x); v.insert(y); pbm = x; } auto dist = [n, &pos](int x, int y){ return min(pos(pos(x)-pos(y)), pos(pos(y)-pos(x))); }; while(q--){ int x, y; cin >> x >> y; int bd = dist(x, y); auto it1 = v.lower_bound(x); if(it1==v.end()){ it1=v.begin(); } auto it2 = v.upper_bound(x); if(it2==v.begin()) it2=v.end(); it2--; bd = min(dist(x, *it1)+dist(*it1+n, y)+1, bd); bd = min(dist(x, *it2)+dist(*it2+n, y)+1, bd); cout << bd << '\n'; } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:6:18: warning: variable 'pbm' set but not used [-Wunused-but-set-variable]
    6 |     int n, m, q, pbm;
      |                  ^~~
#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...