Submission #745484

#TimeUsernameProblemLanguageResultExecution timeMemory
745484MohamedAliSaidaneSplit the Attractions (IOI19_split)C++14
0 / 100
5 ms5076 KiB
#include <bits/stdc++.h> #include "split.h" using namespace std; typedef long long ll; typedef vector<int> vi; #define pb push_back #define ff first #define ss second const int nax = 1e5 + 4; int n, m, a, b, c; vi adj[nax]; vi find_split(int N, int A, int B, int C, vi P, vi Q) { n = N, a = A, b = B, c = C; m = P.size(); for(int i =0 ; i < n; i++) adj[i].clear(); for(int i = 0; i < m; i ++) { adj[P[i]].pb(Q[i]); adj[Q[i]].pb(P[i]); } int root; for(int i =0; i < n ;i ++) { if(adj[i].size() == 1) root = i; } int prec = -1; vi ans(n); for(int i =0; i < n; i++) { if(i >= a) { if(i >= a + b) ans[root] = 3; else ans[root] = 2; } else ans[root] = 1; for(auto e: adj[root]) { if(e != prec) { prec = root; root = e; break; } } } return ans; } /* int32_t main() { int N, M, A, B, C; cin >> N >> M >> A >> B >> C; vi P(M), Q(M); for(int i = 0; i < M; i++) cin >> P[i] >> Q[i]; vi ANS = find_split(N, A, B, C, P, Q); for(auto e: ANS) cout << e << ' '; } */

Compilation message (stderr)

split.cpp: In function 'vi find_split(int, int, int, int, vi, vi)':
split.cpp:42:25: warning: 'root' may be used uninitialized in this function [-Wmaybe-uninitialized]
   42 |                 ans[root] = 3;
      |                         ^
#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...