Submission #409581

#TimeUsernameProblemLanguageResultExecution timeMemory
409581AmineTrabelsiSplit the Attractions (IOI19_split)C++14
0 / 100
64 ms9408 KiB
#include "split.h" #include <bits/stdc++.h> using namespace std; const int Mx = 1e5+5; void get_order(int node,vector<bool> &vis,vector<int> &order,vector<vector<int>> &gr){ order.push_back(node); vis[node] = 1; for(auto i:gr[node]){ if(!vis[i])get_order(i,vis,order,gr); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<vector<int>> gr(n+1,vector<int>()); for(int i=0;i<(int)p.size();i++){ gr[p[i]].push_back(q[i]); gr[q[i]].push_back(p[i]); } vector<bool> vis(n+1,0); vector<int> order; for(int i=0;i<n;i++){ if((int)gr[i].size() == 1){ get_order(i,vis,order,gr); break; } } //cerr<<n<<' '<<order.size()<<'\n'; if((int)order.size() != n){ vector<int> ret(n,0); return ret; } vector<int> res(n,0); int ind = 0; while(a--){ res[order[ind++]] = 1; } while(b--){ res[order[ind++]] = 2; } while(ind < n){ res[order[ind++]] = 3; } return res; }
#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...