Submission #1239189

#TimeUsernameProblemLanguageResultExecution timeMemory
1239189JerCircle Passing (EGOI24_circlepassing)C++20
0 / 100
6 ms328 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 1e7 + 5, MAXM = 2010; int n, m, q; int k; int d[MAXN]; vector<int> con[MAXM]; void find() { set<int> vis; queue<int> q; q.push(0); int l = 0; while (!q.empty()) { int len = q.size(); for (int x = 0; x < len; x++) { int curr = q.front(); q.pop(); if (vis.find(curr) != vis.end()) continue; vis.insert(curr); d[curr] = l; if (curr > 0) q.push(curr - 1); if (curr < 2 * n - 1) q.push(curr + 1); if (curr == 0) q.push(2 * n - 1); if (curr == 2 * n - 1) q.push(0); for (auto i : con[curr]) q.push(i); } l++; } } int main() { scanf("%d%d%d", &n, &m, &q); for (int i = 0; i < m; i++) scanf("%d", &k), con[k].push_back(n + k), con[n + k].push_back(k); find(); int a, b; while (q--) { scanf("%d%d", &a, &b); printf("%d\n", d[b]); } return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:49:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |     scanf("%d%d%d", &n, &m, &q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         scanf("%d", &k), con[k].push_back(n + k), con[n + k].push_back(k);
      |         ~~~~~^~~~~~~~~~
Main.cpp:59:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |         scanf("%d%d", &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...