# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
295708 | mat_v | Split the Attractions (IOI19_split) | C++14 | 621 ms | 1048576 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "split.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define ff(i,a,b) for(int (i) = (a); (i) <= (b); ++(i))
#define fb(i,a,b) for(int (i) = (a); (i) >= (b); --(i))
#define mod 998244353
#define xx first
#define yy second
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define maxn 200005
using namespace std;
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;/// find_by_order(x)(x+1th) , order_of_key() (strictly less)
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
vector<int> graf[maxn];
int N, M;
int subtr[maxn];
int cale[maxn];
void dfs(int x, int last){
subtr[x] = 1;
cale[x] = last;
for(auto c:graf[x]){
if(c == last)continue;
dfs(c, x);
subtr[x] += subtr[c];
}
}
int ost[5];
int sol[maxn];
int fr, se, tr;
void oboji(int x, int last){
if(ost[fr]){
ost[fr]--;
sol[x] = fr;
}
else{
sol[x] = tr;
}
for(auto c:graf[x]){
if(c == last)continue;
oboji(c, x);
}
}
void dfs2(int x){
if(x < 1)return;
if(ost[se]){
ost[se]--;
sol[x] = se;
}
else sol[x] = tr;
for(auto c:graf[x]){
if(sol[c] != 0)continue;
dfs2(c);
}
}
vector<int> find_split(int n, int a, int b, int c, vector<int> p, vector<int> q) {
N = n;
for(int i=0; i<n; i++){
int p1 = p[i] + 1;
int q1 = q[i] + 1;
graf[p1].pb(q1);
graf[q1].pb(p1);
}
M = p.size();
if(1 == 1){
dfs(1,-1);
int sef = -1;
int mini1 = min(a, min(b,c));
int mini2;
if(a == mini1)mini2 = min(b,c);
if(b == mini1)mini2 = min(a,c);
if(c == mini1)mini2 = min(a,b);
ff(i,1,n){
int p1 = subtr[i];
int p2 = n - subtr[i];
if(p1 >= mini1 && p2 >= mini2){
sef = i;
break;
}
if(p1 >= mini2 && p1 >= mini1){
sef = i;
break;
}
}
if(sef == -1){
vector<int> kurac;
ff(i,0,n - 1)kurac.pb(0);
return kurac;
}
ost[1] = a;
ost[2] = b;
ost[3] = c;
int p1 = subtr[sef];
int p2 = n - p1;
fr = 0, se = 0;
if(p1 >= mini1 && p2 >= mini2){
if(mini1 == a)fr = 1;
if(mini1 == b)fr = 2;
if(mini1 == c)fr = 3;
if(mini2 == a && fr != 1)se = 1;
if(mini2 == b && fr != 2)se = 2;
if(mini2 == c && fr != 3)se = 3;
}
else if(p2 >= mini1 && p1 >= mini1){
if(mini2 == a)fr = 1;
if(mini2 == b)fr = 2;
if(mini2 == c)fr = 3;
if(mini1 == a && fr != 1)se = 1;
if(mini1 == b && fr != 2)se = 2;
if(mini1 == c && fr != 3)se = 3;
}
tr = 6 - fr - se;
oboji(sef, cale[sef]);
dfs2(cale[sef]);
vector<int> res;
ff(i,1,n)res.pb(sol[i]);
return res;
}
}
컴파일 시 표준 에러 (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... |