# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
294961 | Ruba_K | Split the Attractions (IOI19_split) | C++14 | 118 ms | 13816 KiB |
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 "split.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5 ;
vector<int>adj[N];
vector<int> res ;
map<int , int > foreach;
int vis[N] , degree[N];
int arr[5];
void dfs(int u , int id , int sz ){
if(sz == arr[id])id++ , sz = 0 ;
vis[u] ++ ;
res[u] = id ;
for(auto f : adj[u]){
if(vis[f])
continue ;
dfs(f , id , sz + 1);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
res.resize(n);
arr[1] = a , arr[2] = b , arr[3] = c ;
int m = p.size();
for(int i = 0 ; i < m ; i ++){
adj[p[i]].push_back(q[i]);
adj[q[i]].push_back(p[i]);
degree[p[i]]++ , degree[q[i]]++;
}
int mn = 3 , start ;
for(int i = 0 ; i < m ; i ++){
if(degree[i] < mn)
mn = degree[i] , start = i ;
}
dfs(start , 1 , 0);
return res;
}
Compilation message (stderr)
# | 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... |