답안 #97190

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97190 2019-02-14T09:49:55 Z maruii Snowy Roads (JOI16_snowy) C++14
100 / 100
30 ms 1932 KB
#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 = 1;
	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 = 1;
	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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 904 KB Output is correct
2 Correct 4 ms 832 KB Output is correct
3 Correct 7 ms 1024 KB Output is correct
4 Correct 8 ms 1044 KB Output is correct
5 Correct 9 ms 1040 KB Output is correct
6 Correct 9 ms 1168 KB Output is correct
7 Correct 12 ms 1224 KB Output is correct
8 Correct 11 ms 1168 KB Output is correct
9 Correct 12 ms 1304 KB Output is correct
10 Correct 12 ms 1180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 11 ms 1300 KB Output is correct
2 Correct 12 ms 1080 KB Output is correct
3 Correct 12 ms 1172 KB Output is correct
4 Correct 16 ms 1172 KB Output is correct
5 Correct 12 ms 1308 KB Output is correct
6 Correct 13 ms 1048 KB Output is correct
7 Correct 15 ms 1176 KB Output is correct
8 Correct 17 ms 1280 KB Output is correct
9 Correct 12 ms 1172 KB Output is correct
10 Correct 13 ms 1300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 1324 KB Output is correct
2 Correct 26 ms 1464 KB Output is correct
3 Correct 23 ms 1240 KB Output is correct
4 Correct 27 ms 1324 KB Output is correct
5 Correct 24 ms 1324 KB Output is correct
6 Correct 16 ms 1308 KB Output is correct
7 Correct 22 ms 1480 KB Output is correct
8 Correct 21 ms 1324 KB Output is correct
9 Correct 23 ms 1324 KB Output is correct
10 Correct 22 ms 1324 KB Output is correct
11 Correct 25 ms 1332 KB Output is correct
12 Correct 18 ms 1324 KB Output is correct
13 Correct 23 ms 1304 KB Output is correct
14 Correct 30 ms 1280 KB Output is correct
15 Correct 20 ms 1324 KB Output is correct
16 Correct 26 ms 1280 KB Output is correct
17 Correct 20 ms 1280 KB Output is correct
18 Correct 23 ms 1324 KB Output is correct
19 Correct 24 ms 1376 KB Output is correct
20 Correct 24 ms 1324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1280 KB Output is correct
2 Correct 23 ms 1264 KB Output is correct
3 Correct 22 ms 1536 KB Output is correct
4 Correct 26 ms 1776 KB Output is correct
5 Correct 23 ms 1792 KB Output is correct
6 Correct 22 ms 1852 KB Output is correct
7 Correct 25 ms 1792 KB Output is correct
8 Correct 21 ms 1736 KB Output is correct
9 Correct 23 ms 1792 KB Output is correct
10 Correct 20 ms 1872 KB Output is correct
11 Correct 25 ms 1848 KB Output is correct
12 Correct 21 ms 1792 KB Output is correct
13 Correct 22 ms 1792 KB Output is correct
14 Correct 18 ms 1888 KB Output is correct
15 Correct 21 ms 1924 KB Output is correct
16 Correct 20 ms 1792 KB Output is correct
17 Correct 19 ms 1792 KB Output is correct
18 Correct 20 ms 1792 KB Output is correct
19 Correct 18 ms 1792 KB Output is correct
20 Correct 26 ms 1848 KB Output is correct
21 Correct 28 ms 1840 KB Output is correct
22 Correct 24 ms 1848 KB Output is correct
23 Correct 21 ms 1848 KB Output is correct
24 Correct 24 ms 1840 KB Output is correct
25 Correct 26 ms 1848 KB Output is correct
26 Correct 27 ms 1840 KB Output is correct
27 Correct 27 ms 1840 KB Output is correct
28 Correct 25 ms 1848 KB Output is correct
29 Correct 21 ms 1916 KB Output is correct
30 Correct 21 ms 1792 KB Output is correct
31 Correct 28 ms 1848 KB Output is correct
32 Correct 20 ms 1852 KB Output is correct
33 Correct 20 ms 1848 KB Output is correct
34 Correct 22 ms 1844 KB Output is correct
35 Correct 20 ms 1792 KB Output is correct
36 Correct 20 ms 1848 KB Output is correct
37 Correct 20 ms 1932 KB Output is correct
38 Correct 20 ms 1848 KB Output is correct
39 Correct 18 ms 1792 KB Output is correct
40 Correct 18 ms 1844 KB Output is correct
41 Correct 20 ms 1844 KB Output is correct
42 Correct 18 ms 1836 KB Output is correct
43 Correct 25 ms 1844 KB Output is correct
44 Correct 20 ms 1844 KB Output is correct
45 Correct 19 ms 1592 KB Output is correct
46 Correct 18 ms 1852 KB Output is correct
47 Correct 17 ms 1844 KB Output is correct
48 Correct 25 ms 1836 KB Output is correct
49 Correct 24 ms 1900 KB Output is correct
50 Correct 18 ms 1844 KB Output is correct