Submission #1047484

#TimeUsernameProblemLanguageResultExecution timeMemory
1047484NotLinuxSplit the Attractions (IOI19_split)C++17
0 / 100
2 ms5212 KiB
#include <bits/stdc++.h> #include "split.h" using namespace std; #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() const int N = 1e5 + 7; vector < int > graph[N] , color; int cur_color = 1; int dfs(int node , int sayac){ if(sayac == 0)return node; // cout << "dfs : " << node << " , " << cur_color << endl; color[node] = cur_color; int ret = -1; for(auto itr : graph[node]){ if(color[itr] == -1){ ret = dfs(itr , sayac - 1); break; } } return ret; } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { color.assign(n , -1); for(int i = 0;i<sz(p);i++){ graph[p[i]-1].push_back(q[i]-1); graph[q[i]-1].push_back(p[i]-1); } bool bl = 1; for(int i = 0;i<n;i++){ bl &= sz(graph[i]) <= 2; } if(bl){ int root = 0; for(int i = 0;i<n;i++){ if(sz(graph[i]) == 1){ root = i; break; } } // cout << "root0 : " << root << endl; root = dfs(root , a); cur_color++; // cout << "root1 : " << root << endl; root = dfs(root , b); cur_color++; // cout << "root2 : " << root << endl; root = dfs(root , c); } return color; }
#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...