이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
static vector<int> edge[500];
static int A[500], B[500], prt[500], dth[500], c[500], N, piv;
static void dfs(int x){
for(auto &i: edge[x]){
if(prt[x]==i) continue;
prt[i] = x;
dth[i] = dth[x]+1;
dfs(i);
}
}
static int dfs2(int x){
int ret = 0;
for(auto &i: edge[x]){
if(prt[x]==i) continue;
c[i] += c[x];
ret = max(ret, dfs2(i)%12+1);
}
if(!x || ret%12 == 0) for(int i=0; i<9; ++i) Save(piv++, (c[x]>>i) & 1);
return ret;
}
void InitAnya(int N_ , int AA[] , int BB[]) {
N = N_;
for(int i=0; i<N; ++i) edge[i].clear();
for(int i=0; i<N-1; ++i){
A[i] = AA[i], B[i] = BB[i];
edge[A[i]].push_back(B[i]);
edge[B[i]].push_back(A[i]);
}
for(int i=0; i<N; ++i) sort(edge[i].begin(), edge[i].end());
dfs(0);
}
void Anya(int C[]) {
for(int i=0; i<N-1; ++i) Save(prt[A[i]]==B[i]?A[i]:B[i], C[i]), c[prt[A[i]]==B[i]?A[i]:B[i]] = C[i];
piv = N;
dfs2(0);
}
#include "Borislib.h"
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
static vector<int> edge[500];
static int A[500], B[500], prt[500], dth[500], piv, pivs[500], chk[500];
static int dfs(int x){
int ret = 0;
for(auto &i: edge[x]){
if(prt[x]==i) continue;
prt[i] = x;
dth[i] = dth[x]+1;
ret = max(ret, dfs(i)%12+1);
}
if(!x || ret%12 == 0) chk[x] = 1, pivs[x] = piv, piv += 9;
return ret;
}
void InitBoris(int N, int AA[], int BB[]) {
for(int i=0; i<N; ++i) edge[i].clear();
for(int i=0; i<N-1; ++i){
A[i] = AA[i], B[i] = BB[i];
edge[A[i]].push_back(B[i]);
edge[B[i]].push_back(A[i]);
}
for(int i=0; i<N; ++i) sort(edge[i].begin(), edge[i].end());
piv = N;
dfs(0);
}
int Boris(int city) {
int ret = 0;
while(!chk[city]) ret += Ask(city), city = prt[city];
for(int i=0; i<9; ++i) ret += Ask(pivs[city]+i)<<i;
return ret;
}
# | 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... |