Submission #1269321

#TimeUsernameProblemLanguageResultExecution timeMemory
1269321sula2Migrations (IOI25_migrations)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; vector<int> adj[10000]; int X = 0, Y = 0; pair<int,int> dfs(int u, int p = -1) { pair<int,int> res = {0, u}; for (int v : adj[u]) { if (v == p) continue; auto z = dfs(v, u); z.first++; res = max(res, z); } return res; } int send_message(int N, int i, int Pi) { adj[i].push_back(Pi); adj[Pi].push_back(i); int nX = 0, nY = 0; if (i >= N-3) { nX = dfs(0).second; nY = dfs(nX).second; if (nX > nY) swap(nX, nY); if (nX == Y) swap(nX, nY); x = nX, y = nY; } int res = 0; if (i == N-2) res = nX; else if (i == N-1) res = i == nX ? nY + N : nY; return res; } pair<int,int> longest_path(vector<int> S) { int n = S.size(); int u = S[n-2]; int v = S[n-1]; if (v >= n) { u = v - n; v = n-1; } return {u, v}; }

Compilation message (stderr)

migrations.cpp: In function 'int send_message(int, int, int)':
migrations.cpp:27:9: error: 'x' was not declared in this scope
   27 |         x = nX, y = nY;
      |         ^
migrations.cpp:27:17: error: 'y' was not declared in this scope
   27 |         x = nX, y = nY;
      |                 ^