답안 #97191

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
97191 2019-02-14T09:50:47 Z maruii Snowy Roads (JOI16_snowy) C++14
100 / 100
27 ms 1528 KB
#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> edge[500];
int A[500], B[500], prt[500], dth[500], c[500], N, piv;
void dfs(int x){
	for(auto &i: edge[x]){
		if(prt[x]==i) continue;
		prt[i] = x;
		dth[i] = dth[x]+1;
		dfs(i);
	}
}
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;
vector<int> edge[500];
int A[500], B[500], prt[500], dth[500], piv, pivs[500], chk[500];
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 5 ms 776 KB Output is correct
2 Correct 5 ms 908 KB Output is correct
3 Correct 9 ms 1088 KB Output is correct
4 Correct 8 ms 1024 KB Output is correct
5 Correct 12 ms 1180 KB Output is correct
6 Correct 14 ms 1280 KB Output is correct
7 Correct 12 ms 1196 KB Output is correct
8 Correct 8 ms 1280 KB Output is correct
9 Correct 12 ms 1304 KB Output is correct
10 Correct 9 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1280 KB Output is correct
2 Correct 13 ms 1300 KB Output is correct
3 Correct 18 ms 1280 KB Output is correct
4 Correct 13 ms 1404 KB Output is correct
5 Correct 13 ms 1044 KB Output is correct
6 Correct 12 ms 1336 KB Output is correct
7 Correct 17 ms 1244 KB Output is correct
8 Correct 11 ms 1280 KB Output is correct
9 Correct 15 ms 1280 KB Output is correct
10 Correct 13 ms 1172 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1388 KB Output is correct
2 Correct 22 ms 1528 KB Output is correct
3 Correct 24 ms 1304 KB Output is correct
4 Correct 22 ms 1280 KB Output is correct
5 Correct 21 ms 1324 KB Output is correct
6 Correct 19 ms 1324 KB Output is correct
7 Correct 19 ms 1280 KB Output is correct
8 Correct 20 ms 1332 KB Output is correct
9 Correct 21 ms 1332 KB Output is correct
10 Correct 21 ms 1332 KB Output is correct
11 Correct 25 ms 1360 KB Output is correct
12 Correct 20 ms 1388 KB Output is correct
13 Correct 27 ms 1332 KB Output is correct
14 Correct 21 ms 1036 KB Output is correct
15 Correct 26 ms 1328 KB Output is correct
16 Correct 21 ms 1332 KB Output is correct
17 Correct 19 ms 1280 KB Output is correct
18 Correct 22 ms 1332 KB Output is correct
19 Correct 20 ms 1332 KB Output is correct
20 Correct 24 ms 1096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1324 KB Output is correct
2 Correct 23 ms 1288 KB Output is correct
3 Correct 20 ms 1280 KB Output is correct
4 Correct 20 ms 1328 KB Output is correct
5 Correct 22 ms 1304 KB Output is correct
6 Correct 23 ms 1316 KB Output is correct
7 Correct 23 ms 1316 KB Output is correct
8 Correct 22 ms 1316 KB Output is correct
9 Correct 24 ms 1312 KB Output is correct
10 Correct 20 ms 1416 KB Output is correct
11 Correct 22 ms 1352 KB Output is correct
12 Correct 25 ms 1316 KB Output is correct
13 Correct 24 ms 1320 KB Output is correct
14 Correct 22 ms 1148 KB Output is correct
15 Correct 22 ms 1280 KB Output is correct
16 Correct 20 ms 1276 KB Output is correct
17 Correct 21 ms 1312 KB Output is correct
18 Correct 20 ms 1320 KB Output is correct
19 Correct 22 ms 1320 KB Output is correct
20 Correct 24 ms 1364 KB Output is correct
21 Correct 22 ms 1068 KB Output is correct
22 Correct 20 ms 1332 KB Output is correct
23 Correct 26 ms 1304 KB Output is correct
24 Correct 20 ms 1320 KB Output is correct
25 Correct 21 ms 1264 KB Output is correct
26 Correct 26 ms 1280 KB Output is correct
27 Correct 20 ms 1244 KB Output is correct
28 Correct 19 ms 1320 KB Output is correct
29 Correct 21 ms 1312 KB Output is correct
30 Correct 23 ms 1320 KB Output is correct
31 Correct 24 ms 1304 KB Output is correct
32 Correct 20 ms 1344 KB Output is correct
33 Correct 20 ms 1280 KB Output is correct
34 Correct 24 ms 1308 KB Output is correct
35 Correct 21 ms 1280 KB Output is correct
36 Correct 27 ms 1456 KB Output is correct
37 Correct 20 ms 1280 KB Output is correct
38 Correct 20 ms 1320 KB Output is correct
39 Correct 19 ms 1280 KB Output is correct
40 Correct 19 ms 1280 KB Output is correct
41 Correct 18 ms 1324 KB Output is correct
42 Correct 14 ms 1280 KB Output is correct
43 Correct 22 ms 1280 KB Output is correct
44 Correct 20 ms 1280 KB Output is correct
45 Correct 21 ms 1120 KB Output is correct
46 Correct 14 ms 1280 KB Output is correct
47 Correct 22 ms 1308 KB Output is correct
48 Correct 22 ms 1280 KB Output is correct
49 Correct 19 ms 1316 KB Output is correct
50 Correct 18 ms 1280 KB Output is correct