# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
226333 | AaronNaidu | Split the Attractions (IOI19_split) | C++14 | 6 ms | 2688 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100001];
int n, a, b, c, num;
bool visited[100001];
vector<int> toRet;
int parent[100001];
int subSize[100001];
int num1 = 0;
int num2 = 0;
int dfs(int node, int par) {
visited[node] = true;
parent[node] = par;
int subsize = 1;
for (auto i : graph[node])
{
if (!visited[i])
{
subsize += dfs(i, node);
}
}
subSize[node] = subsize;
return subsize;
}
void dfs1(int node) {
num1++;
if (num1 > a)
{
return;
}
toRet[node] = 10;
for (auto i : graph[node])
{
if (i != parent[node])
{
if(num1 > a) {
return;
}
dfs1(i);
}
}
}
void dfs2(int node) {
num2++;
if (num2 > b)
{
return;
}
toRet[node] = 20;
for (auto i : graph[node])
{
if (i != parent[node] and toRet[node] == 3)
{
if(num1 > a) {
return;
}
dfs2(i);
}
}
}
vector<int> find_split(int ln, int la, int lb, int lc, vector<int> p, vector<int> q) {
n = ln;
a = la;
b = lb;
c = lc;
vector<int> v = {a, b, c};
sort(v.begin(), v.end());
a = v[0];
b = v[1];
c = v[2];
for (int i = 0; i < p.size(); i++)
{
graph[p[i]].push_back(q[i]);
graph[q[i]].push_back(p[i]);
}
for (int i = 0; i < n; i++)
{
toRet.push_back(30);
}
num = 0;
dfs(0, -1);
int best = n+1;
int bestVertex = -1;
for (int i = 0; i < n; i++)
{
if (subSize[i] >= a)
{
if (best > subSize[i])
{
best = subSize[i];
bestVertex = i;
}
}
}
//cout << "Best is " << best << " at vertex " << bestVertex << "\n";
if (n - best < b)
{
for (int i = 0; i < n; i++)
{
toRet[i] = 0;
}
return toRet;
}
dfs1(bestVertex);
dfs2(0);
if (a >= b and b >= c)
{
for (int i = 0; i < n; i++)
{
if (toRet[i] == 10)
{
toRet[i] = 3;
}
else if (toRet[i] == 20)
{
toRet[i] = 2;
}
else
{
toRet[i] = 1;
}
}
}
else if (a >= c and c >= b)
{
for (int i = 0; i < n; i++)
{
if (toRet[i] == 10)
{
toRet[i] = 2;
}
else if (toRet[i] == 20)
{
toRet[i] = 3;
}
else
{
toRet[i] = 1;
}
}
}
else if (b >= a and a >= c)
{
for (int i = 0; i < n; i++)
{
if (toRet[i] == 10)
{
toRet[i] = 3;
}
else if (toRet[i] == 20)
{
toRet[i] = 1;
}
else
{
toRet[i] = 2;
}
}
}
else if (b >= c and c >= a)
{
for (int i = 0; i < n; i++)
{
if (toRet[i] == 10)
{
toRet[i] = 1;
}
else if (toRet[i] == 20)
{
toRet[i] = 3;
}
else
{
toRet[i] = 2;
}
}
}
else if (c >= a and a >= b)
{
for (int i = 0; i < n; i++)
{
if (toRet[i] == 10)
{
toRet[i] = 2;
}
else if (toRet[i] == 20)
{
toRet[i] = 1;
}
else
{
toRet[i] = 3;
}
}
}
else if (c >= b and b >= a)
{
for (int i = 0; i < n; i++)
{
if (toRet[i] == 10)
{
toRet[i] = 1;
}
else if (toRet[i] == 20)
{
toRet[i] = 2;
}
else
{
toRet[i] = 3;
}
}
}
return toRet;
}
컴파일 시 표준 에러 (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... |