답안 #26111

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26111 2017-06-28T04:42:21 Z 김현수(#1096) Snowy Roads (JOI16_snowy) C++11
100 / 100
22 ms 4184 KB
#include "Anyalib.h"
#include<bits/stdc++.h>
using namespace std;

static int n, sum[1005], par[505], idx[505], val[505];

static vector<int> adj[505], arr;

static void calc (int C, int P) {
	par[C] = P;
	arr.push_back(C);
	for(auto &T : adj[C]) {
		if(T == P) continue;
		calc(T, C);
	}
	arr.push_back(-C);
}

static void write (int S, int L, int V) {
	for(int i=0;i<L;i++) {
		Save(S+i, V%2);
		V /= 2;
	}
}

void InitAnya(int N, int A[] , int B[]) {
	n = N;
	for(int i=0;i<N-1;i++) {
		adj[A[i]].push_back(B[i]);
		adj[B[i]].push_back(A[i]);
	}
	arr.push_back(0);
	calc(0, 0);
	for(int i=0;i<N-1;i++) {
		idx[i] = (par[A[i]] == B[i] ? A[i] : B[i]);
	}
}

void Anya(int C[]) {
	for(int i=0;i<n-1;i++) val[idx[i]] = C[i];
	for(int i=1;i<=2*n;i++) {
		sum[i] = sum[i-1] + (arr[i] < 0 ? -val[-arr[i]] : val[arr[i]]);
	}
	for(int i=0;20*i+1<=2*n;i++) write(10*i, 10, sum[20*(i+1)]);
	for(int i=0;i<n;i++) Save(500+i, val[i]);
}
#include "Borislib.h"
#include<bits/stdc++.h>
using namespace std;

static int n, inv[505];

static vector<int> adj[505], arr;

static void calc (int C, int P) {
	inv[C] = arr.size();
	arr.push_back(C);
	for(auto &T : adj[C]) {
		if(T == P) continue;
		calc(T, C);
	}
	arr.push_back(-C);
}

static int read (int S, int L) {
	int R = 0;
	for(int i=0;i<L;i++) {
		R += (1<<i) * Ask(S+i);
	}
	return R;
}

static int getval (int P) {
	if(arr[P] < 0) return -Ask(500-arr[P]);
	else return Ask(500+arr[P]);
}

void InitBoris(int N , int A[], int B[]) {
	n = N;
	for(int i=0;i<n-1;i++) {
		adj[A[i]].push_back(B[i]);
		adj[B[i]].push_back(A[i]);
	}
	arr.push_back(0);
	calc(0, 0);
}

int Boris (int C) {
	int V = 0, I = inv[C];
	if(I % 20 <= 10) {
		I -= I%20;
		V = (I ? read(I/2-10, 10) : 0);
		for(int i=I+1;i<=inv[C];i++) {
			V += getval(i);
		}
	}
	else {
		I -= I%20 - 20;
		V = (I ? read(I/2-10, 10) : 0);
		for(int i=I;i>inv[C];i--) {
			V -= getval(i);
		}
	}
	return V;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 4184 KB Output is correct
2 Correct 0 ms 4184 KB Output is correct
3 Correct 0 ms 4184 KB Output is correct
4 Correct 0 ms 4184 KB Output is correct
5 Correct 6 ms 4184 KB Output is correct
6 Correct 6 ms 4184 KB Output is correct
7 Correct 0 ms 4184 KB Output is correct
8 Correct 3 ms 4184 KB Output is correct
9 Correct 3 ms 4184 KB Output is correct
10 Correct 0 ms 4184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 4184 KB Output is correct
2 Correct 6 ms 4184 KB Output is correct
3 Correct 6 ms 4184 KB Output is correct
4 Correct 3 ms 4184 KB Output is correct
5 Correct 6 ms 4184 KB Output is correct
6 Correct 6 ms 4184 KB Output is correct
7 Correct 6 ms 4184 KB Output is correct
8 Correct 6 ms 4184 KB Output is correct
9 Correct 6 ms 4184 KB Output is correct
10 Correct 6 ms 4184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 4184 KB Output is correct
2 Correct 12 ms 4184 KB Output is correct
3 Correct 16 ms 4184 KB Output is correct
4 Correct 13 ms 4184 KB Output is correct
5 Correct 6 ms 4184 KB Output is correct
6 Correct 12 ms 4184 KB Output is correct
7 Correct 16 ms 4184 KB Output is correct
8 Correct 12 ms 4184 KB Output is correct
9 Correct 16 ms 4184 KB Output is correct
10 Correct 12 ms 4184 KB Output is correct
11 Correct 16 ms 4184 KB Output is correct
12 Correct 19 ms 4184 KB Output is correct
13 Correct 12 ms 4184 KB Output is correct
14 Correct 12 ms 4184 KB Output is correct
15 Correct 16 ms 4184 KB Output is correct
16 Correct 13 ms 4184 KB Output is correct
17 Correct 9 ms 4184 KB Output is correct
18 Correct 12 ms 4184 KB Output is correct
19 Correct 12 ms 4184 KB Output is correct
20 Correct 16 ms 4184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 4184 KB Output is correct
2 Correct 12 ms 4184 KB Output is correct
3 Correct 12 ms 4184 KB Output is correct
4 Correct 12 ms 4184 KB Output is correct
5 Correct 16 ms 4184 KB Output is correct
6 Correct 12 ms 4184 KB Output is correct
7 Correct 12 ms 4184 KB Output is correct
8 Correct 12 ms 4184 KB Output is correct
9 Correct 6 ms 4184 KB Output is correct
10 Correct 12 ms 4184 KB Output is correct
11 Correct 12 ms 4184 KB Output is correct
12 Correct 12 ms 4184 KB Output is correct
13 Correct 9 ms 4184 KB Output is correct
14 Correct 12 ms 4184 KB Output is correct
15 Correct 6 ms 4184 KB Output is correct
16 Correct 12 ms 4184 KB Output is correct
17 Correct 19 ms 4184 KB Output is correct
18 Correct 16 ms 4184 KB Output is correct
19 Correct 16 ms 4184 KB Output is correct
20 Correct 9 ms 4184 KB Output is correct
21 Correct 9 ms 4184 KB Output is correct
22 Correct 16 ms 4184 KB Output is correct
23 Correct 9 ms 4184 KB Output is correct
24 Correct 12 ms 4184 KB Output is correct
25 Correct 16 ms 4184 KB Output is correct
26 Correct 19 ms 4184 KB Output is correct
27 Correct 19 ms 4184 KB Output is correct
28 Correct 16 ms 4184 KB Output is correct
29 Correct 9 ms 4184 KB Output is correct
30 Correct 12 ms 4184 KB Output is correct
31 Correct 9 ms 4184 KB Output is correct
32 Correct 19 ms 4184 KB Output is correct
33 Correct 16 ms 4184 KB Output is correct
34 Correct 22 ms 4184 KB Output is correct
35 Correct 12 ms 4184 KB Output is correct
36 Correct 13 ms 4184 KB Output is correct
37 Correct 9 ms 4184 KB Output is correct
38 Correct 12 ms 4184 KB Output is correct
39 Correct 19 ms 4184 KB Output is correct
40 Correct 12 ms 4184 KB Output is correct
41 Correct 16 ms 4184 KB Output is correct
42 Correct 15 ms 4184 KB Output is correct
43 Correct 16 ms 4184 KB Output is correct
44 Correct 16 ms 4184 KB Output is correct
45 Correct 9 ms 4184 KB Output is correct
46 Correct 12 ms 4184 KB Output is correct
47 Correct 9 ms 4184 KB Output is correct
48 Correct 12 ms 4184 KB Output is correct
49 Correct 12 ms 4184 KB Output is correct
50 Correct 12 ms 4184 KB Output is correct