# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147634 | nandonathaniel | Split the Attractions (IOI19_split) | C++14 | 120 ms | 12972 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 MAXN=100005;
int cntB,warna[MAXN];
vector<int> adj[MAXN];
bool visited[MAXN];
int sudah=0;
bool keluar=false;
void dfs(int now){
//cout << "now " << now << endl;
if(sudah==cntB){
keluar=true;
return;
}
visited[now]=true;
warna[now]=2;
sudah++;
for(int i=0;i<adj[now].size();i++){
int nxt=adj[now][i];
if(!visited[nxt]){
dfs(nxt);
}
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
memset(visited,0,sizeof(visited));
memset(warna,0,sizeof(warna));
cntB=b;
vector<int> res;
for(int i=0;i<p.size();i++){
adj[p[i]].push_back(q[i]);
adj[q[i]].push_back(p[i]);
}
dfs(0);
bool sudah=false;
for(int i=0;i<n;i++){
if(warna[i]==0){
if(!sudah){
warna[i]=1;
sudah=true;
}
else warna[i]=3;
}
res.push_back(warna[i]);
}
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... |