#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> res;
int m=p.size();
//cout<<m<<endl;
int connected[m][2];
bool visited[m];
for(int i=0;i<n;i++)
{
connected[i][0]=-1;
connected[i][1]=-1;
visited[i]=false;
res.push_back(3);
}
for(int i=0;i<m;i++)
{
int x=p[i];
int y=q[i];
if(connected[x][0]==-1) connected[x][0]=y;
else connected[x][1]=y;
if(connected[y][0]==-1) connected[y][0]=x;
else connected[y][1]=x;
}
int startpos=-1;
int endpos=-1;
for(int i=0;i<n;i++)
{
if(connected[i][0]==-1 || connected[i][1]==-1)
{
if(startpos==-1) startpos=i;
else endpos=i;
}
}
if(startpos==-1)
{
bool error=false;
startpos=0;
int startcount=0;
while(startcount<a)
{
visited[startpos]=true;
res[startpos]=1;
startcount++;
if(visited[connected[startpos][0]]==true)
{
if(visited[connected[startpos][1]]==true)
{
error=true;
break;
}
startpos=connected[startpos][1];
}
else startpos=connected[startpos][0];
}
int endcount=0;
endpos=startpos;
while(endcount<b)
{
visited[endpos]=true;
res[endpos]=2;
endcount++;
if(visited[connected[endpos][0]]==true)
{
if(visited[connected[endpos][1]]==true)
{
error=true;
break;
}
endpos=connected[endpos][1];
}
else endpos=connected[endpos][0];
}
if(error==true)
{
for(int i=0;i<n;i++)
{
res[i]=0;
}
}
return res;
}
bool error=false;
int startcount=0;
while(startcount<a)
{
visited[startpos]=true;
res[startpos]=1;
startcount++;
if(visited[connected[startpos][0]]==true)
{
if(visited[connected[startpos][1]]==true)
{
error=true;
break;
}
startpos=connected[startpos][1];
}
else startpos=connected[startpos][0];
}
int endcount=0;
while(endcount<b)
{
visited[endpos]=true;
res[endpos]=2;
endcount++;
if(visited[connected[endpos][0]]==true)
{
if(visited[connected[endpos][1]]==true)
{
error=true;
break;
}
endpos=connected[endpos][1];
}
else endpos=connected[endpos][0];
}
if(error==true)
{
for(int i=0;i<n;i++)
{
res[i]=0;
}
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ok, correct split |
2 |
Correct |
0 ms |
212 KB |
ok, correct split |
3 |
Correct |
0 ms |
212 KB |
ok, correct split |
4 |
Correct |
0 ms |
212 KB |
ok, correct split |
5 |
Correct |
1 ms |
212 KB |
ok, correct split |
6 |
Correct |
0 ms |
212 KB |
ok, correct split |
7 |
Correct |
29 ms |
3280 KB |
ok, correct split |
8 |
Correct |
30 ms |
3396 KB |
ok, correct split |
9 |
Correct |
34 ms |
3272 KB |
ok, correct split |
10 |
Correct |
33 ms |
3392 KB |
ok, correct split |
11 |
Correct |
30 ms |
3252 KB |
ok, correct split |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ok, correct split |
2 |
Correct |
0 ms |
212 KB |
ok, correct split |
3 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ok, correct split |
2 |
Runtime error |
37 ms |
3396 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ok, correct split |
2 |
Correct |
0 ms |
212 KB |
ok, correct split |
3 |
Correct |
0 ms |
212 KB |
ok, correct split |
4 |
Correct |
0 ms |
212 KB |
ok, correct split |
5 |
Correct |
1 ms |
212 KB |
ok, correct split |
6 |
Correct |
0 ms |
212 KB |
ok, correct split |
7 |
Correct |
29 ms |
3280 KB |
ok, correct split |
8 |
Correct |
30 ms |
3396 KB |
ok, correct split |
9 |
Correct |
34 ms |
3272 KB |
ok, correct split |
10 |
Correct |
33 ms |
3392 KB |
ok, correct split |
11 |
Correct |
30 ms |
3252 KB |
ok, correct split |
12 |
Correct |
1 ms |
212 KB |
ok, correct split |
13 |
Correct |
0 ms |
212 KB |
ok, correct split |
14 |
Runtime error |
1 ms |
340 KB |
Execution killed with signal 6 |
15 |
Halted |
0 ms |
0 KB |
- |