Submission #1058094

#TimeUsernameProblemLanguageResultExecution timeMemory
1058094kachim2Circle Passing (EGOI24_circlepassing)C++17
100 / 100
316 ms52692 KiB
#include<bits/stdc++.h> using namespace std; int main(){ int64_t n, m, q, pbm; cin >> n >> m >> q; set<int64_t> v; auto pos = [n](int64_t x){ return ((x)+2*n)%(2*n); }; for(int64_t i = 0; i < m; i++){ int64_t x; cin >> x; int64_t y = pos(x+n); v.insert(x); v.insert(y); pbm = x; } auto dist = [n, &pos](int64_t x, int64_t y){ return min(pos(pos(x)-pos(y)), pos(pos(y)-pos(x))); }; while(q--){ int64_t x, y; cin >> x >> y; int64_t 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:22: warning: variable 'pbm' set but not used [-Wunused-but-set-variable]
    6 |     int64_t 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...