#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef pair<int,int>P;
#include "Anyalib.h"
static vector<int>E[600];
static int dep[600];
static int a[600],b[600];
static map<int,int>mp,edge;
int n;
static void dfs(int v,int p,int d){
dep[v]=d;
for(int u:E[v]){
if(u==p)continue;
dfs(u,v,d+1);
}
}
void InitAnya(int N , int A[] , int B[]) {
n=N;
rep(i,n-1){
a[i]=A[i];b[i]=B[i];
E[a[i]].push_back(b[i]);
E[b[i]].push_back(a[i]);
}
dfs(0,-1,0);
int cnt=0;
for(int i=1;i<n;i++){
if(dep[i]%12==0){
mp[i]=cnt;
cnt+=9;
}
}
rep(i,n-1){
if(dep[a[i]]>dep[b[i]])swap(a[i],b[i]);
edge[b[i]]=cnt++;
}
assert(cnt<=1000);
}
static int dist[600];
static int c[600];
static void dfs2(int v,int p,int d){
dist[v]=d;
for(int u:E[v]){
if(u==p)continue;
dfs2(u,v,d+c[u]);
}
}
void Anya(int C[]) {
rep(i,n-1){
if(C[i])c[b[i]]=1;
else c[b[i]]=0;
}
dfs2(0,-1,0);
for(int i=1;i<n;i++){
if(dep[i]%12==0){
int st=mp[i];
rep(j,9){
Save(st+j,dist[i]>>j&1);
}
}
Save(edge[i],c[i]);
}
}
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
#include "Borislib.h"
static vector<int>E[600];
static int dep[600];
static int a[600],b[600];
static map<int,int>mp,edge;
static int par[600];
static void dfs(int v,int p,int d){
dep[v]=d;
for(int u:E[v]){
if(u==p)continue;
dfs(u,v,d+1);
}
}
void InitBoris(int N , int A[] , int B[]) {
rep(i,N-1){
a[i]=A[i];b[i]=B[i];
E[a[i]].push_back(b[i]);
E[b[i]].push_back(a[i]);
}
dfs(0,-1,0);
int cnt=0;
for(int i=1;i<N;i++){
if(dep[i]%12==0){
mp[i]=cnt;
cnt+=9;
}
}
rep(i,N-1){
if(dep[a[i]]>dep[b[i]])swap(a[i],b[i]);
edge[b[i]]=cnt++;
par[b[i]]=a[i];
}
}
int Boris(int city) {
int cnt=0;
while(1){
if(city==0)break;
if(dep[city]%12==0){
int st=mp[city];
rep(i,9){
cnt+=(Ask(st+i)<<i);
}
break;
}
cnt+=Ask(edge[city]);
city=par[city];
}
return cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
784 KB |
Output is correct |
2 |
Correct |
6 ms |
916 KB |
Output is correct |
3 |
Correct |
7 ms |
1064 KB |
Output is correct |
4 |
Correct |
9 ms |
1144 KB |
Output is correct |
5 |
Correct |
9 ms |
1040 KB |
Output is correct |
6 |
Correct |
10 ms |
1400 KB |
Output is correct |
7 |
Correct |
9 ms |
1168 KB |
Output is correct |
8 |
Correct |
10 ms |
1168 KB |
Output is correct |
9 |
Correct |
9 ms |
1168 KB |
Output is correct |
10 |
Correct |
12 ms |
1168 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
1280 KB |
Output is correct |
2 |
Correct |
13 ms |
1300 KB |
Output is correct |
3 |
Correct |
13 ms |
1300 KB |
Output is correct |
4 |
Correct |
12 ms |
1308 KB |
Output is correct |
5 |
Correct |
14 ms |
1280 KB |
Output is correct |
6 |
Correct |
13 ms |
1280 KB |
Output is correct |
7 |
Correct |
13 ms |
1300 KB |
Output is correct |
8 |
Correct |
18 ms |
1300 KB |
Output is correct |
9 |
Correct |
15 ms |
1172 KB |
Output is correct |
10 |
Correct |
12 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
1400 KB |
Output is correct |
2 |
Correct |
31 ms |
1280 KB |
Output is correct |
3 |
Correct |
33 ms |
1344 KB |
Output is correct |
4 |
Correct |
32 ms |
1324 KB |
Output is correct |
5 |
Correct |
33 ms |
1336 KB |
Output is correct |
6 |
Correct |
33 ms |
1280 KB |
Output is correct |
7 |
Correct |
39 ms |
1332 KB |
Output is correct |
8 |
Correct |
33 ms |
1336 KB |
Output is correct |
9 |
Correct |
37 ms |
1324 KB |
Output is correct |
10 |
Correct |
37 ms |
1332 KB |
Output is correct |
11 |
Correct |
28 ms |
1324 KB |
Output is correct |
12 |
Correct |
36 ms |
1324 KB |
Output is correct |
13 |
Correct |
32 ms |
1332 KB |
Output is correct |
14 |
Correct |
34 ms |
1332 KB |
Output is correct |
15 |
Correct |
35 ms |
1332 KB |
Output is correct |
16 |
Correct |
31 ms |
1332 KB |
Output is correct |
17 |
Correct |
33 ms |
1316 KB |
Output is correct |
18 |
Correct |
39 ms |
1296 KB |
Output is correct |
19 |
Correct |
38 ms |
1332 KB |
Output is correct |
20 |
Correct |
35 ms |
1280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |