# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154175 | asifthegreat | Split the Attractions (IOI19_split) | C++14 | 126 ms | 18808 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 <bits/stdc++.h>
#include "split.h"
using namespace std;
const int N = 300000;
vector<int>graph[N];
int mark[N];
int vis[N];
int baki;
void dfs(int at){
if(baki == 0)return;
// printf("%d here am I \n",at);
mark[at] = 2;
baki--;
vis[at] = true;
for(auto i: graph[at]){
if(vis[i] == true){
// cout <<i << " how can it be visited?\n";
continue;
}
dfs(i);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int> res;
// vector<int> something;
// something.push_back(a);
// something.push_back(c);
// something.push_back(b);
// sort(something.first(),something.second());
// a = something[0],b=something[1],c=something[2];
for(int i = 0; i < p.size();i++){
// printf("The pair is ( %d %d )\n",p[i],q[i] );
graph[p[i]].push_back(q[i]);
graph[q[i]].push_back(p[i]);
}
baki = b;
// printf("%d\n",baki );
memset(vis,0,sizeof vis);
dfs(0);
for(int i = 0; i < n;i++){
if(!vis[i]){
vis[i] = true;
mark[i]= 1;
break;
}
}
for(int i = 0; i < n;i++){
if(!vis[i]){
vis[i] = true;
mark[i]= 3;
// break;
}
}
for(int i = 0; i < n;i++){
res.push_back(mark[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... |