Submission #297140

#TimeUsernameProblemLanguageResultExecution timeMemory
297140AzimjonSplit the Attractions (IOI19_split)C++17
0 / 100
73 ms8952 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { int m = p.size(); vector<vi> g(n, vi()); for (int i = 0; i < m; i++) { g[p[i]].push_back(q[i]); g[q[i]].push_back(p[i]); } vi jv(n, 0); int bo, ox; for (int i = 0; i < n; i++) if (g[i].size() == 1) { bo = i; break; } for (int i = 0; i < n; i++) if (g[i].size() == 1 && i != bo) { ox = i; break; } for (int i = 0; i < a; i++) { jv[bo] = 1; if (g[bo].size() == 2) { if (jv[g[bo][0]]) bo = g[bo][1]; else bo = g[bo][0]; } else bo = g[bo][0]; } for (int i = 0; i < b; i++) { jv[ox] = 2; if (g[ox].size() == 2) { if (jv[g[ox][0]]) ox = g[ox][1]; else ox = g[ox][0]; } else ox = g[ox][0]; } for (int &i : jv) if (i == 0) i = 3; return jv; }

Compilation message (stderr)

split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:25:24: warning: 'bo' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |   if (g[i].size() == 1 && i != bo) {
      |       ~~~~~~~~~~~~~~~~~^~~~~~~~~~
split.cpp:43:8: warning: 'ox' may be used uninitialized in this function [-Wmaybe-uninitialized]
   43 |   jv[ox] = 2;
      |        ^
#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...