제출 #427587

#제출 시각아이디문제언어결과실행 시간메모리
427587dreezySplit the Attractions (IOI19_split)C++17
0 / 100
99 ms11844 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; #define pb push_back const int maxn = 1e5 + 5; vector<int> graph[maxn]; int a, b, c; //assume a is smallest //assume b is second smallest vector<int> ans; int cnt = 0; bool dfs(int n, int p){ cnt++; ans[n] = 2; if(cnt == b){ return true; } for(int adj : graph[n]){ if(adj == p) continue; if(dfs(adj, n)) return true; } return cnt == b; } vector<int> find_split(int n, int a_, int b_, int c_, vector<int> p, vector<int> q) { a = a_; b = b_; c = c_; int m = p.size(); ans.assign(n, 3); for(int i =0; i<m ;i++){ //cout << p[i] <<", "<<q[i]<<endl; graph[p[i]].pb(q[i]); graph[q[i]].pb(p[i]); } if(b) dfs(0, -1); 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...