# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
169817 | arthur_nascimento | Split the Attractions (IOI19_split) | C++14 | 46 ms | 7032 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;
#define pb push_back
#define debug
#define ll long long
#define maxn 2525
#define pii pair<int,int>
using namespace std;
int sz[3];
int id0,id1,id2;
int ans[maxn];
vector<int> L[maxn];
int vis[maxn];
int color(int vx,int qtd,int to){
//qtd--;
//ans[vx] = to; debug("+%d\n",vx);
queue<int> Q;
Q.push(vx);
vis[vx] = 1;
while(qtd){
int nov = Q.front();
Q.pop();
ans[nov] = to;debug("+%d\n",nov);
qtd--;
for(int i=0;i<L[nov].size();i++){
int yy = L[nov][i];
if(!vis[yy]){
vis[yy] = 1; debug("push %d\n",yy);
Q.push(yy);
}
}
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
sz[0] = a;
sz[1] = b;
sz[2] = c;
for(int i=0;i<p.size();i++)
L[p[i]].pb(q[i]), L[q[i]].pb(p[i]);
vector<pii> vv;
for(int i=0;i<3;i++){
vv.pb(pii(sz[i],i));
}
sort(vv.begin(),vv.end());
id0 = vv[0].second;
id1 = vv[1].second;
id2 = vv[2].second;
for(int i=0;i<n;i++) ans[i] = id2+1;
if(sz[id0] == 1){
color(0,sz[id1],id1+1);
for(int i=0;i<n;i++)
if(ans[i] == id2+1){
ans[i] = id0+1;
break;
}
}
vector<int> res;
for(int i=0;i<n;i++) res.pb(ans[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... |