Submission #1195687

#TimeUsernameProblemLanguageResultExecution timeMemory
1195687badge881Circle Passing (EGOI24_circlepassing)C++20
100 / 100
830 ms141572 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { int n, m, q, a, b; scanf("%lld%lld%lld", &n, &m, &q); set<int> s; while (m--) { scanf("%lld", &a); s.insert(a - n); s.insert(a - 2 * n); s.insert(a); s.insert(a + n); s.insert(a + 2 * n); s.insert(a + 3 * n); } while (q--) { scanf("%lld%lld", &a, &b); if (a > b) b += 2 * n; int ans = min(b - a, a - b + 2 * n); auto it = s.lower_bound(a); ans = min(ans, abs(*it + n - b) + abs(*it - a) + 1); --it; ans = min(ans, abs(*it + n - b) + abs(*it - a) + 1); printf("%lld\n", ans); } }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |     scanf("%lld%lld%lld", &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%lld", &a);
      |         ~~~~~^~~~~~~~~~~~
Main.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%lld%lld", &a, &b);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~
#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...