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"
using namespace std;
#include <iostream>
/*
10 9
3 5 2
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 0
*/
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
vector<int> res(n, 3);
vector<vector<int> > g(n);
for(int i = 0; i < p.size(); i++) {
g[p[i]].push_back(q[i]);
g[q[i]].push_back(p[i]);
}
bool volt = false;
for(int i = 0; i < n; i++) {
if(g[i].size() == 1) {
volt = true;
int x = i, y = -1;
for(int j = 0; j < a; j++) {
res[x] = 1;
int temp = x;
if(g[x][0] == y) {
x = g[x][1];
} else {
x = g[x][0];
}
y = temp;
}
for(int j = 0; j < b; j++) {
res[x] = 2;
int temp = x;
if(g[x][0] == y) {
x = g[x][1];
} else {
x = g[x][0];
}
y = temp;
}
break;
}
}
if(!volt) {
int x = 0, y = -1;
for(int j = 0; j < a; j++) {
res[x] = 1;
int temp = x;
if(g[x][0] == y) {
x = g[x][1];
} else {
x = g[x][0];
}
y = temp;
}
for(int j = 0; j < b; j++) {
res[x] = 2;
int temp = x;
if(g[x][0] == y) {
x = g[x][1];
} else {
x = g[x][0];
}
y = temp;
}
}
/*if (n == 9) {
res = {1, 1, 3, 1, 2, 2, 3, 1, 3};
} else {
res = {0, 0, 0, 0, 0, 0};
}*/
return res;
}
Compilation message (stderr)
split.cpp: In function 'std::vector<int> find_split(int, int, int, int, std::vector<int>, std::vector<int>)':
split.cpp:24:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
24 | for(int i = 0; i < p.size(); i++) {
| ~~^~~~~~~~~~
# | 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... |