# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1014789 | alex_2008 | Split the Attractions (IOI19_split) | C++14 | 1093 ms | 1048576 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 <iostream>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10, M = 110;
vector <vector<int>> G;
vector<int> find_split(int n, int A, int B, int C, vector<int> p, vector<int> q) {
int m = (int)p.size();
bool sb1 = true, sb2 = true;
G.resize(n);
for (int i = 0; i < m; i++) {
G[p[i]].push_back(q[i]);
G[q[i]].push_back(p[i]);
}
for (int i = 0; i < n; i++) {
if ((int)G[i].size() > 2) sb1 = false;
}
if (sb1) {
int a = -1, b = -1;
for (int i = 0; i < n; i++) {
if ((int)G[i].size() == 1) {
if (a == -1) a = i;
else b = i;
}
}
vector <int> v;
if (a != -1) {
v.push_back(a);
v.push_back(G[a][0]);
while (v.back() != b) {
int a = v[(int)v.size() - 1];
int b = v[(int)v.size() - 2];
if (G[a][0] == b) v.push_back(G[a][1]);
else v.push_back(G[a][0]);
}
}
else {
v.push_back(a);
v.push_back(G[a][0]);
while (v.size() != n) {
int last = v.back();
if (G[last][0] != v[(int)v.size() - 2]) v.push_back(G[last][0]);
else v.push_back(G[last][1]);
}
}
vector <int> ans(n);
for (int i = 0; i < n; i++) {
if (i < A) ans[v[i]] = 1;
else if (i < A + B) ans[v[i]] = 2;
else ans[v[i]] = 3;
}
return ans;
}
}
/*int main() {
}*/
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... |