QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#416414#412. Snowy Roads10circle0 18ms4032kbC++142.1kb2024-05-21 20:18:132024-05-21 20:18:13

Judging History

你现在查看的是最新测评结果

  • [2024-05-21 20:18:13]
  • 评测
  • 测评结果:0
  • 用时:18ms
  • 内存:4032kb
  • [2024-05-21 20:18:13]
  • 提交

Anya

#include "Anyalib.h"

static int getL;

#include <bits/stdc++.h>
using namespace std;

namespace awa {

typedef vector<int> vint;

const int N = 505;
vint e[N];
int pa[N], is[N], cnt, st[N], ep[N], dp[N], n;

int dfs(int u, int p) {
	dp[u] = dp[p] + 1, pa[u] = p;
	int xd = 0;
	for (int v : e[u]) if (v != p) {
		xd = max(xd, dfs(v, u) + 1);
	}
	st[u] = cnt;
	if (xd >= 9) {
		is[u] = 1;
		cnt += 9;
		return -1;
	} else cnt++;
	return xd;
}

void InitAnya(int N, int a[], int b[]) {
	n = N;
	for (int i = 0; i + 1 < n; ++i) e[a[i]].push_back(b[i]), e[b[i]].push_back(a[i]);
	dfs(0, 0);
	for (int i = 0; i + 1 < n; ++i) ep[i] = (dp[a[i]] < dp[b[i]] ? b[i] : a[i]);
	
}

int nu[N], ok[N];

void dfs2(int u) {
	for (int v : e[u]) if (v != pa[u]) nu[v] = nu[u] + ok[v], dfs2(v);
	if (is[u]) {
		for (int k = 0; k < 9; ++k) Save(st[u] + k, (nu[u] >> k) & 1);
	} else Save(st[u], ok[u]);
}

void Anya(int C[]) {
	for (int i = 0; i + 1 < n; ++i) ok[ep[i]] = C[i];
	dfs2(0);
}
}

void InitAnya(int N, int a[], int b[]) { awa::InitAnya(N, a, b); }
void Anya(int C[]) { awa::Anya(C); }

Boris

#include "Borislib.h"


#include <bits/stdc++.h>
using namespace std;

namespace bwb {

typedef vector<int> vint;

const int N = 505;
vint e[N];
int pa[N], is[N], cnt, st[N], ep[N], dp[N], n;

int dfs(int u, int p) {
	dp[u] = dp[p] + 1, pa[u] = p;
	int xd = 0;
	for (int v : e[u]) if (v != p) {
		xd = max(xd, dfs(v, u) + 1);
	}
	st[u] = cnt;
	if (xd >= 9) {
		is[u] = 1;
		cnt += 9;
		return -1;
	} else cnt++;
	return xd;
}

void InitBoris(int N, int a[], int b[]) {
	n = N;
	for (int i = 0; i + 1 < n; ++i) e[a[i]].push_back(b[i]), e[b[i]].push_back(a[i]);
	dfs(0, 0);
	for (int i = 0; i + 1 < n; ++i) ep[i] = (dp[a[i]] < dp[b[i]] ? b[i] : a[i]);
	
}

int Boris(int u) {
	if (u == 0) return 0;
	if (is[u]) {
		int as = 0;
		for (int k = 0; k < 9; ++k) as = (Ask(st[u] + k) << k);
		return as;
	}
	return Boris(pa[u]) + Ask(st[u]);
}
}


void InitBoris(int N, int a[], int b[]) { bwb::InitBoris(N, a, b); }
int Boris(int C) { return bwb::Boris(C); }

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 15
Accepted
time: 2ms
memory: 3812kb

input:

2
0 1

1
0 
1
0 
1
0 
1
1 
1
1 
1
1 
1
1 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
1 
1
1 
1
1 
1
0 
1
1 
1
1 
1
1 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0 
1
1 
1
1 
1
1 
1
1 
1
1 
1
1 
1
1 
1
1 
1
1 
1
0 
1
0 
1
0 
1
0 
1
0 
1
0...

output:

0 -1
0
0 -1
0
0 -1
0
0 -1
1
0 -1
1
0 -1
1
0 -1
1
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -1
0
0 -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
1
2

result:

ok 50 numbers

Test #3:

score: 15
Accepted
time: 7ms
memory: 3876kb

input:

16
6 12
1 10
2 14
6 8
3 14
6 15
3 7
2 15
0 13
6 10
0 15
5 10
5 11
9 11
4 15

9
1 0 1 1 1 0 
10
0 0 0 
11
1 1 1 1 1 
15
1 
12
1 1 1 
6
0 0 
8
0 0 0 
13
0 
1
0 1 1 1 
2
0 1 
7
1 0 1 1 0 
3
1 1 0 0 
4
0 0 
5
0 0 1 1 
14
0 1 1 
12
0 0 0 
7
1 1 0 1 1 
8
1 1 1 
9
0 0 0 0 0 0 
4
0 0 
13
0 
11
0 0 0 0 0 
3
...

output:

14 8 7 6 5 4 -1
4
14 8 7 -1
0
14 8 7 6 5 -1
5
14 -1
1
14 8 1 -1
3
14 8 -1
0
14 8 2 -1
0
0 -1
0
14 8 7 3 -1
3
14 12 -1
1
14 12 11 10 9 -1
3
14 12 11 10 -1
2
14 13 -1
0
14 8 7 6 -1
2
14 12 11 -1
2
14 8 1 -1
0
14 12 11 10 9 -1
4
14 8 2 -1
3
14 8 7 6 5 4 -1
0
14 13 -1
0
0 -1
0
14 8 7 6 5 -1
0
14 12 11 1...

input:


output:

4
0
5
1
3
0
0
0
3
1
3
2
0
2
2
0
4
3
0
0
0
0
1
3
0
0
1
0
3
2
1
1
0
3
0
1
1
0
2
1
3
2
1
1
0
2
4
1
2
1
2
1
2
1
0
1
0
0
0
2
0
1
0
1
0
0
1
2
0
1
0
0
1
1
2
3
0
2
1
1
0
3
3
0
3
3
2
1
4
0
2
3
1
0
3
1
3
2
1
1
0
0
0
2
0
2
4
3
1
2
1
1
1
1
3
1
1
1
1
0
1
1
3
0
3
1
2
2
3
1
1
2
1
2
1
0
1
0
0
1
0
2
0
0
2
2
3
4
1
1
...

result:

ok 200 numbers

Test #4:

score: 0
Wrong Answer
time: 0ms
memory: 3956kb

input:

18
1 7
2 3
3 14
10 15
5 11
8 12
0 4
7 9
3 8
6 8
7 17
0 13
9 13
7 14
10 16
10 11
5 6

15
0 1 0 0 0 0 0 0 0 1 1 0 1 1 0 1 0 1 
1
1 0 0 0 0 0 0 0 0 1 0 
3
1 0 0 0 0 0 0 0 0 1 1 0 
14
1 0 0 0 0 0 0 0 0 0 1 
6
1 0 0 0 0 0 0 0 0 1 1 1 0 1 
10
1 0 0 0 0 0 0 0 0 1 1 1 0 1 0 0 0 
16
1 0 0 0 0 0 0 0 0 0 0 1 0...

output:

15 16 17 18 19 20 21 22 23 14 13 12 11 10 9 8 7 5 -1
6
15 16 17 18 19 20 21 22 23 14 1 -1
1
15 16 17 18 19 20 21 22 23 14 13 12 -1
2
15 16 17 18 19 20 21 22 23 14 13 -1
1
15 16 17 18 19 20 21 22 23 14 13 12 11 10 -1
4
15 16 17 18 19 20 21 22 23 14 13 12 11 10 9 8 7 -1
4
15 16 17 18 19 20 21 22 23 14...

input:


output:

6
1
2
1
4 4
4
1
3
0
3
2
6 3
1
0
0 4
0
4
1
1
0 2
5
0
5
1
2
6
0
2
1
2
5 8
0
0
0
0
4
2
2
9
0
1
0
2 1 2
1
3
2
2
0
5
0
3 2
6
0
1
2
0
1 2
1 4
1
3
0
1
2
0
3
3
1
0
5
2
3
0
1
0
0 1
0
0
2
4 2
1
0
1
3 1
6 1 3
1
1
4
0
2 6
4
1
2
1
0 0
1
2
3
1
3
3
1
1
5
3
4
0
0 0
1
1
1
0
3
3
0
0 0
2 2 2
2
1
1
2
0
1
2
0 0
3
4
1
0 ...

result:

wrong answer 1st numbers differ - expected: '8', found: '6'

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 5ms
memory: 3868kb

input:

77
16 67
48 53
9 31
42 66
1 39
48 60
35 57
36 48
3 67
5 26
8 74
47 72
14 62
28 30
2 9
33 71
24 70
22 47
18 32
49 71
51 67
5 17
11 30
1 57
44 48
8 21
16 32
42 63
25 61
1 38
45 48
8 67
25 29
25 49
15 63
50 74
10 76
0 56
2 75
35 69
57 72
52 73
10 55
34 52
65 68
12 20
6 36
7 34
25 27
12 59
36 37
10 32
1...

output:

74 75 76 77 78 79 80 81 82 36 35 34 32 23 21 -1
6
74 75 76 77 78 79 80 81 82 67 -1
0
74 75 76 77 78 79 80 81 82 36 35 -1
1
74 75 76 77 78 79 80 81 82 73 72 71 -1
2
74 75 76 77 78 79 80 81 82 55 54 53 47 46 45 44 43 -1
4
74 75 76 77 78 79 80 81 82 73 72 71 70 -1
3
74 75 76 77 78 79 80 81 82 -1
0
74 7...

input:


output:

6
0
1
2
4
3
0
1
2
0
3
2
3
2
2
4
2
4
3
0
4
3
0
1
1
0
1
4
8
6
2
3
3
2
2
1
3
1
2
2
3
3
2
0
5
3
2
0
0
1
0
4
2
1
5
3
0
1
3
0
2
4
2
0
3
1
3
2
3
2
2
2
3
2
3
1
1
0
1
1
2
1
2
3
2
3
1
2
1
3
2
0
1
1
3
4
2
2
2
3
1
2
5
2
4
4
1
2
0
2
5
2
1
1
4
0
0
2
3
0
0
2
1
0
2
3
2
5
0
3
1
4
3
2
3
2
2
1
2
1
3
2
1
0
3
5
2
2
2
1
...

result:

wrong answer 1st numbers differ - expected: '8', found: '6'

Subtask #3:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 4ms
memory: 4032kb

input:

500
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
52 ...

output:

333 334 335 336 337 338 339 340 341 332 -1
1
171 172 173 174 175 176 177 178 179 -1
0
81 82 83 84 85 86 87 88 89 80 79 78 77 76 75 74 73 72 -1
4
693 694 695 696 697 698 699 700 701 692 691 690 689 688 687 686 685 684 -1
3
387 388 389 390 391 392 393 394 395 386 -1
1
297 298 299 300 301 302 303 304 3...

input:


output:

1
0
4
3
1
0
264
1
0
3
0
0
256
5
264
0
0
4
0
4
1
0
0
4
1
2
2
0
0
3
1
0
4
3
0
0
2
0
3
0
2
2
1
1
3
2
4
4
1
1
6
2
3
5
1
1
5
1
2
0
3
3
6
2
7
0
0
4
2
6
0
3
1
5
2
2
3
0
1
5
2
4
1
1
2
2
0
0
3
4
1
3
0
2
2
3
2
3
6
3
5
2
5
264
6
1
1
1
1
0
6
0
2
3
0
0
2
1
0
3
1
5
2
0
1
1
4
0
0
3
2
5
3
0
3
4
4
5
0
8
5
2
2
0
2
5
...

result:

wrong answer 1st numbers differ - expected: '134', found: '1'

Subtask #4:

score: 0
Wrong Answer

Test #41:

score: 0
Wrong Answer
time: 18ms
memory: 3836kb

input:

500
142 378
158 398
67 460
271 330
157 315
97 288
0 487
2 193
132 190
90 446
187 367
204 485
60 455
161 188
164 351
9 245
30 423
82 163
124 207
89 187
237 294
382 428
189 218
212 409
45 69
339 413
129 364
132 147
292 417
434 471
276 399
101 286
88 134
296 386
250 374
153 340
139 304
171 213
9 382
19...

output:

289 290 291 292 293 294 295 296 297 288 266 233 232 231 230 -1
4
312 313 314 315 316 317 318 319 320 302 194 186 166 164 163 -1
4
312 313 314 315 316 317 318 319 320 302 194 186 185 182 181 180 179 178 -1
6
145 146 147 148 149 150 151 152 153 134 132 131 130 129 128 127 126 -1
5
289 290 291 292 293 ...

input:


output:

4
4
6
5
0
4
0
2
4
1
4
2
2
0
6
7
3
2
0
0
2
1
3
0
6
3
5
2
1
1
1
2
1
3
4
3
2
0
0
2
3
1
5
8
0
6
3
1
0
3
4
3
4
4
0
2
2
2
1
0
0
0
5
2
2
1
2
5
3
6
3
3
3
2
0
4
0
1
4
4
2
2
3
3
4
2
4
1
0
7
3
3
3
1
4
1
1
4
1
4
0
2
2
1
4
4
1
1
1
3
3
2
1
3
2
5
5
5
2
0
1
3
3
1
3
2
0
0
3
6
3
2
1
0
3
2
0
3
2
1
2
5
1
0
2
2
2
1
1
4
...

result:

wrong answer 1st numbers differ - expected: '11', found: '4'