Submission #288970

#TimeUsernameProblemLanguageResultExecution timeMemory
288970mohammadSplit the Attractions (IOI19_split)C++14
11 / 100
134 ms15732 KiB
#include "split.h" #include<bits/stdc++.h> using namespace std; #define endl "\n" // #define int long long typedef long long ll ; const ll ooo = 1e14 ; const ll oo = 2e9 ; const double PI = acos(-1) ; const ll M = 1e9 + 7 ; const int N = 10000010 ; int use[200010]; vector<int> v[200010] , seq; void dfs(int u ){ seq.push_back(u); use[u] = 1; for(auto x : v[u]) if(!use[x]){ dfs(x); } } vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) { vector<int> res; int m = p.size(); for(int i = 0 ; i < m ; ++i) { v[p[i]].push_back(q[i]); v[q[i]].push_back(p[i]); } dfs(0); if(b > c){ res = vector<int>(n , 2); for(int i = 0 ; i < c ; ++i) res[seq[i]] = 3; for(int i = 0 ; i < n ; ++i) if(res[i] == 2){ res[i] = 1; break; } }else{ res = vector<int>(n , 3); // cout << seq[0] for(int i = 0 ; i < b ; ++i) res[seq[i]] = 2; for(int i = 0 ; i < n ; ++i) if(res[i] == 3){ res[i] = 1; break; } } 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...