제출 #745483

#제출 시각아이디문제언어결과실행 시간메모리
745483MohamedAliSaidaneSplit the Attractions (IOI19_split)C++14
0 / 100
4 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 < 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 << ' '; } */

컴파일 시 표준 에러 (stderr) 메시지

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