Submission #583771

#TimeUsernameProblemLanguageResultExecution timeMemory
583771joelauSplit the Attractions (IOI19_split)C++14
11 / 100
81 ms12704 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; int N,M,A,B,C; vector<int> lst[100005], ans; queue<int> Q; vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { N = n, M = p.size(), A = a, B = b, C = c; for (int i = 0; i < M; ++i) lst[p[i]].push_back(q[i]), lst[q[i]].push_back(p[i]); ans.assign(N,3); ans[0] = 2; Q.push(0); int cnt = 1; while (!Q.empty() && cnt < B) { int u = Q.front(); Q.pop(); for (int v: lst[u]) if (ans[v] == 3) { ans[v] = 2, cnt++; Q.push(v); if (cnt >= B) break; } } for (int i = 0; i < N; ++i) if (ans[i] == 3) { ans[i] = 1; break; } return ans; }
#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...