This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "bits/stdc++.h"
using namespace std;
vector<int> adj[100001];
vector<pair<int,int>> v;
int vis[100001];
void precomp(int i,int dep){
vis[i] = 1;
v.push_back({dep,i});
for(auto j:adj[i]){
if(!vis[j])continue;
precomp(j,dep+1);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p,vector<int> q){
for(int i = 0;i<p.size();i++){
adj[p[i]].push_back(q[i]);
adj[q[i]].push_back(p[i]);
}
int inda = 1 , indb = 2 , indc = 3;
if(a>b){swap(a,b);swap(inda,indb);}
if(b>c){swap(b,c);swap(indb,indc);}
if(a>b){swap(a,b);swap(inda,indb);}
if(b>c){swap(b,c);swap(indb,indc);}
precomp(0,0);
sort(v.begin(),v.end());
reverse(v.begin(),v.end());
vector<int> ans(n,0);
for(int i = 0;i<v.size();i++){
if(i<a)ans[v[i].second] = inda;
else if(i<b+a)ans[v[i].second] = indb;
else ans[v[i].second] = indc;
}
return ans;
}
Compilation message (stderr)
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:16:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
16 | for(int i = 0;i<p.size();i++){
| ~^~~~~~~~~
split.cpp:29:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | for(int i = 0;i<v.size();i++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |