답안 #257507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
257507 2020-08-04T11:10:23 Z songc Snowy Roads (JOI16_snowy) C++14
100 / 100
55 ms 4400 KB
#include "Anyalib.h"
#include <bits/stdc++.h>
using namespace std;

static int N, D[550], S[550], P[550];
static int A[550], B[550], C[550][550];
static vector<int> adj[550], V;

static void dfs(int u, int p, int c){
	D[u] = 1, P[u] = c;
	for (int v : adj[u]){
		if (v == p) continue;
		dfs(v, u, c+C[u][v]);
		D[u] += D[v];
	}
	if (D[u] >= 11 || u==0) D[u]=0, V.push_back(u);
}

void InitAnya(int n, int a[], int b[]) {
	N=n;
	for (int i=0; i<N; i++) adj[i].clear();
	for (int i=0; i<N-1; i++){
		A[i] = a[i], B[i] = b[i];
		adj[A[i]].push_back(B[i]);
		adj[B[i]].push_back(A[i]);
	}
}

void Anya(int c[]) {
	memset(C, 0, sizeof C);
	for (int i=0; i<N-1; i++) C[A[i]][B[i]] = C[B[i]][A[i]] = c[i], Save(i, c[i]);
	V.clear();
	dfs(0, -1, 0);
	for (int i=0; i<V.size(); i++) for (int j=0; j<9; j++) Save(N-1+i*9+j, !!(P[V[i]]&(1<<j)));
}
#include "Borislib.h"
#include <bits/stdc++.h>
using namespace std;

static int N, D[550], S[550], P[550], X[550], num;
static int A[550], B[550], C[550][550];
static vector<int> adj[550];

static void dfs(int u, int p){
	D[u] = 1, P[u] = p;
	for (int v : adj[u]){
		if (v == p) continue;
		dfs(v, u);
		D[u] += D[v];
	}
	if (D[u] >= 11 || u==0) D[u]=0, X[u]=++num;
}

void InitBoris(int n, int a[], int b[]) {
	N=n, num=0;
	memset(S, 0, sizeof S);
	memset(X, 0, sizeof X);
	for (int i=0; i<N; i++) adj[i].clear();
	for (int i=0; i<N-1; i++){
		A[i] = a[i], B[i] = b[i];
		C[A[i]][B[i]] = C[B[i]][A[i]] = i;
		adj[A[i]].push_back(B[i]);
		adj[B[i]].push_back(A[i]);
	}
	dfs(0, -1);
}

int Boris(int u){
	int ans=0;
	while (!X[u]){
		ans += Ask(C[u][P[u]]);
		u = P[u];
	}
	for (int i=0; i<9; i++) if (Ask(N-1+(X[u]-1)*9+i)) ans += (1<<i);
	return ans;
}

Compilation message

Anya.cpp: In function 'void Anya(int*)':
Anya.cpp:34:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<V.size(); i++) for (int j=0; j<9; j++) Save(N-1+i*9+j, !!(P[V[i]]&(1<<j)));
                ~^~~~~~~~~
Anya.cpp: At global scope:
Anya.cpp:5:23: warning: 'S' defined but not used [-Wunused-variable]
 static int N, D[550], S[550], P[550];
                       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3072 KB Output is correct
2 Correct 4 ms 3072 KB Output is correct
3 Correct 9 ms 3328 KB Output is correct
4 Correct 16 ms 3328 KB Output is correct
5 Correct 28 ms 3584 KB Output is correct
6 Correct 26 ms 3584 KB Output is correct
7 Correct 24 ms 3576 KB Output is correct
8 Correct 24 ms 3568 KB Output is correct
9 Correct 40 ms 3568 KB Output is correct
10 Correct 27 ms 3576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 3568 KB Output is correct
2 Correct 28 ms 3584 KB Output is correct
3 Correct 28 ms 3656 KB Output is correct
4 Correct 26 ms 3568 KB Output is correct
5 Correct 26 ms 3584 KB Output is correct
6 Correct 28 ms 3608 KB Output is correct
7 Correct 27 ms 3568 KB Output is correct
8 Correct 28 ms 3584 KB Output is correct
9 Correct 27 ms 3584 KB Output is correct
10 Correct 31 ms 3664 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 3632 KB Output is correct
2 Correct 37 ms 4104 KB Output is correct
3 Correct 39 ms 4336 KB Output is correct
4 Correct 49 ms 4080 KB Output is correct
5 Correct 46 ms 4080 KB Output is correct
6 Correct 41 ms 4168 KB Output is correct
7 Correct 42 ms 4128 KB Output is correct
8 Correct 36 ms 4080 KB Output is correct
9 Correct 39 ms 4144 KB Output is correct
10 Correct 36 ms 4168 KB Output is correct
11 Correct 35 ms 4188 KB Output is correct
12 Correct 37 ms 4304 KB Output is correct
13 Correct 36 ms 4156 KB Output is correct
14 Correct 35 ms 4080 KB Output is correct
15 Correct 36 ms 4164 KB Output is correct
16 Correct 36 ms 4144 KB Output is correct
17 Correct 47 ms 4264 KB Output is correct
18 Correct 36 ms 4164 KB Output is correct
19 Correct 36 ms 4080 KB Output is correct
20 Correct 36 ms 4160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 3568 KB Output is correct
2 Correct 37 ms 4080 KB Output is correct
3 Correct 40 ms 4080 KB Output is correct
4 Correct 36 ms 4184 KB Output is correct
5 Correct 38 ms 4080 KB Output is correct
6 Correct 40 ms 4336 KB Output is correct
7 Correct 37 ms 4080 KB Output is correct
8 Correct 37 ms 4080 KB Output is correct
9 Correct 37 ms 4080 KB Output is correct
10 Correct 37 ms 4232 KB Output is correct
11 Correct 41 ms 4080 KB Output is correct
12 Correct 36 ms 4344 KB Output is correct
13 Correct 40 ms 4080 KB Output is correct
14 Correct 39 ms 4184 KB Output is correct
15 Correct 40 ms 4080 KB Output is correct
16 Correct 34 ms 4080 KB Output is correct
17 Correct 47 ms 4080 KB Output is correct
18 Correct 40 ms 4328 KB Output is correct
19 Correct 38 ms 4080 KB Output is correct
20 Correct 37 ms 4088 KB Output is correct
21 Correct 37 ms 4140 KB Output is correct
22 Correct 36 ms 4152 KB Output is correct
23 Correct 43 ms 4172 KB Output is correct
24 Correct 36 ms 4080 KB Output is correct
25 Correct 37 ms 4080 KB Output is correct
26 Correct 39 ms 4080 KB Output is correct
27 Correct 39 ms 4080 KB Output is correct
28 Correct 38 ms 4080 KB Output is correct
29 Correct 49 ms 4184 KB Output is correct
30 Correct 47 ms 4184 KB Output is correct
31 Correct 37 ms 4188 KB Output is correct
32 Correct 36 ms 4080 KB Output is correct
33 Correct 37 ms 4400 KB Output is correct
34 Correct 36 ms 4080 KB Output is correct
35 Correct 37 ms 4080 KB Output is correct
36 Correct 39 ms 4080 KB Output is correct
37 Correct 55 ms 4080 KB Output is correct
38 Correct 39 ms 4152 KB Output is correct
39 Correct 46 ms 4080 KB Output is correct
40 Correct 37 ms 4080 KB Output is correct
41 Correct 36 ms 4200 KB Output is correct
42 Correct 36 ms 4080 KB Output is correct
43 Correct 39 ms 4120 KB Output is correct
44 Correct 37 ms 4196 KB Output is correct
45 Correct 37 ms 4080 KB Output is correct
46 Correct 35 ms 4080 KB Output is correct
47 Correct 35 ms 4080 KB Output is correct
48 Correct 35 ms 4080 KB Output is correct
49 Correct 36 ms 4080 KB Output is correct
50 Correct 36 ms 4080 KB Output is correct