Submission #100970

# Submission time Handle Problem Language Result Execution time Memory
100970 2019-03-15T14:16:37 Z autumn_eel None (JOI16_snowy) C++14
100 / 100
66 ms 2032 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);
	}
}
static int mod;
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 MP[12]{};
	for(int i=1;i<n;i++){
		MP[dep[i]%12]++;
	}
	mod=min_element(MP,MP+12)-MP;
	int cnt=0;
	for(int i=1;i<n;i++){
		if(dep[i]%12==mod){
			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==mod){
			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 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);
	}
}
static int mod;
void InitBoris(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 MP[12]{};
	for(int i=1;i<n;i++){
		MP[dep[i]%12]++;
	}
	mod=min_element(MP,MP+12)-MP;
	int cnt=0;
	for(int i=1;i<N;i++){
		if(dep[i]%12==mod){
			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==mod){
			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 5 ms 912 KB Output is correct
2 Correct 4 ms 988 KB Output is correct
3 Correct 7 ms 1088 KB Output is correct
4 Correct 9 ms 1108 KB Output is correct
5 Correct 10 ms 1300 KB Output is correct
6 Correct 11 ms 1408 KB Output is correct
7 Correct 10 ms 1280 KB Output is correct
8 Correct 9 ms 1280 KB Output is correct
9 Correct 9 ms 1304 KB Output is correct
10 Correct 11 ms 1040 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1300 KB Output is correct
2 Correct 12 ms 1420 KB Output is correct
3 Correct 13 ms 1420 KB Output is correct
4 Correct 13 ms 1292 KB Output is correct
5 Correct 14 ms 1300 KB Output is correct
6 Correct 11 ms 1280 KB Output is correct
7 Correct 13 ms 1112 KB Output is correct
8 Correct 10 ms 1300 KB Output is correct
9 Correct 15 ms 1432 KB Output is correct
10 Correct 15 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1316 KB Output is correct
2 Correct 35 ms 1520 KB Output is correct
3 Correct 29 ms 1264 KB Output is correct
4 Correct 33 ms 1316 KB Output is correct
5 Correct 34 ms 1336 KB Output is correct
6 Correct 33 ms 1296 KB Output is correct
7 Correct 33 ms 1332 KB Output is correct
8 Correct 30 ms 1324 KB Output is correct
9 Correct 37 ms 1316 KB Output is correct
10 Correct 31 ms 1296 KB Output is correct
11 Correct 33 ms 1408 KB Output is correct
12 Correct 30 ms 1320 KB Output is correct
13 Correct 28 ms 1332 KB Output is correct
14 Correct 30 ms 1344 KB Output is correct
15 Correct 32 ms 1280 KB Output is correct
16 Correct 31 ms 1324 KB Output is correct
17 Correct 31 ms 1332 KB Output is correct
18 Correct 37 ms 1324 KB Output is correct
19 Correct 30 ms 1428 KB Output is correct
20 Correct 29 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1264 KB Output is correct
2 Correct 29 ms 1320 KB Output is correct
3 Correct 30 ms 1776 KB Output is correct
4 Correct 29 ms 1792 KB Output is correct
5 Correct 30 ms 1864 KB Output is correct
6 Correct 32 ms 1824 KB Output is correct
7 Correct 32 ms 1792 KB Output is correct
8 Correct 30 ms 1816 KB Output is correct
9 Correct 40 ms 1776 KB Output is correct
10 Correct 34 ms 1836 KB Output is correct
11 Correct 45 ms 1828 KB Output is correct
12 Correct 34 ms 1736 KB Output is correct
13 Correct 34 ms 1860 KB Output is correct
14 Correct 39 ms 1856 KB Output is correct
15 Correct 36 ms 1836 KB Output is correct
16 Correct 30 ms 1824 KB Output is correct
17 Correct 37 ms 2032 KB Output is correct
18 Correct 38 ms 1824 KB Output is correct
19 Correct 32 ms 1832 KB Output is correct
20 Correct 31 ms 1836 KB Output is correct
21 Correct 35 ms 1864 KB Output is correct
22 Correct 36 ms 2016 KB Output is correct
23 Correct 34 ms 2032 KB Output is correct
24 Correct 33 ms 1804 KB Output is correct
25 Correct 39 ms 1828 KB Output is correct
26 Correct 37 ms 2032 KB Output is correct
27 Correct 33 ms 1600 KB Output is correct
28 Correct 33 ms 1820 KB Output is correct
29 Correct 29 ms 1836 KB Output is correct
30 Correct 29 ms 1868 KB Output is correct
31 Correct 30 ms 1876 KB Output is correct
32 Correct 33 ms 1876 KB Output is correct
33 Correct 38 ms 1944 KB Output is correct
34 Correct 32 ms 1912 KB Output is correct
35 Correct 33 ms 1800 KB Output is correct
36 Correct 33 ms 1884 KB Output is correct
37 Correct 31 ms 1868 KB Output is correct
38 Correct 41 ms 1828 KB Output is correct
39 Correct 31 ms 1776 KB Output is correct
40 Correct 29 ms 1796 KB Output is correct
41 Correct 29 ms 1792 KB Output is correct
42 Correct 28 ms 1776 KB Output is correct
43 Correct 28 ms 1824 KB Output is correct
44 Correct 32 ms 2032 KB Output is correct
45 Correct 30 ms 1796 KB Output is correct
46 Correct 66 ms 1824 KB Output is correct
47 Correct 32 ms 1792 KB Output is correct
48 Correct 30 ms 1824 KB Output is correct
49 Correct 34 ms 1864 KB Output is correct
50 Correct 30 ms 1792 KB Output is correct