# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
551498 | PiejanVDC | Split the Attractions (IOI19_split) | C++17 | 1 ms | 212 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;
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int>adj[n];
const int m = (int)p.size();
for(int i = 0 ; i < m ; i++) {
adj[p[i]].push_back(q[i]);
adj[q[i]].push_back(p[i]);
}
vector<int>col(n,0);
int start = 0;
for(int i = 0 ; i < n ; i++)
if((int)adj[i].size() == 1)
start = i;
stack<int>s;
s.push(start);
int sz = 1;
col[start] = 2;
vector<bool>vis(n,0);
vis[start] = 1;
vector<bool>real(n,0);
while(sz < b) {
int node = s.top();
s.pop();
real[node] = 1;
col[node] = 2;
sz++;
for(auto z : adj[node]) if(!vis[z]) {
s.push(z);
vis[z] = 1;
}
}
vis.clear();
vis.resize(n,0);
for(int i = 0 ; i < n ; i++) {
if(!real[i]) {
while(!s.empty())
s.pop();
s.push(i);
sz = 1;
vis[i] = 1;
col[i] = 1;
while(sz < a) {
int node = s.top();
s.pop();
sz++;
col[node] = 1;
for(auto z : adj[node]) if(!vis[z]) {
s.push(z);
vis[z] = 1;
}
}
break;
}
}
for(int i = 0 ; i < n ; i++)
if(!col[i])
col[i] = 3;
return col;
}
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... |