Submission #100966

# Submission time Handle Problem Language Result Execution time Memory
100966 2019-03-15T13:43:14 Z autumn_eel None (JOI16_snowy) C++14
55 / 100
40 ms 1520 KB
#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++;
	}
}

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;
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 832 KB Output is correct
2 Correct 5 ms 832 KB Output is correct
3 Correct 8 ms 1088 KB Output is correct
4 Correct 11 ms 1024 KB Output is correct
5 Correct 11 ms 1304 KB Output is correct
6 Correct 13 ms 1304 KB Output is correct
7 Correct 12 ms 1168 KB Output is correct
8 Correct 10 ms 1280 KB Output is correct
9 Correct 12 ms 1168 KB Output is correct
10 Correct 14 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 1280 KB Output is correct
2 Correct 16 ms 1280 KB Output is correct
3 Correct 11 ms 1300 KB Output is correct
4 Correct 12 ms 1280 KB Output is correct
5 Correct 11 ms 1420 KB Output is correct
6 Correct 12 ms 1280 KB Output is correct
7 Correct 17 ms 1320 KB Output is correct
8 Correct 12 ms 1308 KB Output is correct
9 Correct 12 ms 1280 KB Output is correct
10 Correct 14 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 1304 KB Output is correct
2 Correct 33 ms 1324 KB Output is correct
3 Correct 35 ms 1296 KB Output is correct
4 Correct 33 ms 1332 KB Output is correct
5 Correct 40 ms 1332 KB Output is correct
6 Correct 33 ms 1348 KB Output is correct
7 Correct 34 ms 1332 KB Output is correct
8 Correct 32 ms 1520 KB Output is correct
9 Correct 31 ms 1344 KB Output is correct
10 Correct 34 ms 1468 KB Output is correct
11 Correct 35 ms 1444 KB Output is correct
12 Correct 32 ms 1332 KB Output is correct
13 Correct 33 ms 1316 KB Output is correct
14 Correct 33 ms 1368 KB Output is correct
15 Correct 34 ms 1324 KB Output is correct
16 Correct 35 ms 1316 KB Output is correct
17 Correct 35 ms 1332 KB Output is correct
18 Correct 33 ms 1360 KB Output is correct
19 Correct 36 ms 1312 KB Output is correct
20 Correct 33 ms 1520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 904 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -