# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
826941 | vjudge1 | Split the Attractions (IOI19_split) | C++17 | 484 ms | 1048576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "split.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define en '\n'
#define all(v) v.begin(),v.end()
#define pii pair <int,int>
#define f first
#define s second
#define mp make_pair
using namespace std;
const int N = 3e5 + 10;
vector <int> g[N];
int cnt,color,n;
vector <pii> order;
int a[N],sz[N];
void dfs(int v) {
if(cnt == 0)return;
cnt--;
a[v] = color;
if(cnt == 0)return;
for(auto to : g[v]) {
if(a[to])continue;
dfs(to);
}
}
bool ch;
void dfs_build(int v,int p) {
//cout << v << endl;
sz[v] = 1;
for(auto to : g[v]) {
if(to == p)continue;
//cout << to << endl;
dfs_build(to,v);
if(ch)return;
sz[v] += sz[to];
}
if(sz[v] >= order[0].f && n - sz[v] >= order[1].f) {
//cout << "option 1" << endl;
a[v] = order[0].s;
a[p] = order[1].s;
color = order[0].s;
cnt = order[0].f;
dfs(v);
color = order[1].s;
cnt = order[1].f;
dfs(p);
ch = 1;
}else if(sz[v] >= order[1].f && n - sz[v] >= order[0].f) {
//cout << "option 2" << endl;
a[v] = order[1].s;
a[p] = order[0].s;
color = order[1].s;
cnt = order[1].f;
dfs(v);
color = order[0].s;
cnt = order[0].f;
dfs(p);
ch = 1;
}
}
vector<int> find_split(int NN, int A, int B, int C, vector<int> p, vector<int> q) {
n = NN;
order.pb(mp(A,1));
order.pb(mp(B,2));
order.pb(mp(C,3));
sort(all(order));
A = order[0].f;
B = order[1].f;
C = order[2].f;
for(int i = 0;i < p.size();i++) {
p[i]++;
q[i]++;
g[p[i]].pb(q[i]);
g[q[i]].pb(p[i]);
}
dfs_build(1,-1);
if(ch) {
for(int i = 1;i <= n;i++) {
if(!a[i])a[i] = order[2].s;
}
}
vector <int> ans;
for(int i = 1;i <= n;i++)ans.pb(a[i]);
return ans;
}
컴파일 시 표준 에러 (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... |