QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#601511#2004. Crocodile's Underground Cityiframe#46 1ms8028kbC++17786b2024-09-30 03:25:582024-09-30 03:25:58

Judging History

This is the latest submission verdict.

  • [2024-09-30 03:25:58]
  • Judged
  • Verdict: 46
  • Time: 1ms
  • Memory: 8028kb
  • [2024-09-30 03:25:58]
  • Submitted

answer

#include "crocodile.h"

#include <iostream>
#include <vector>
#include <array>

using ll = long long;

std::vector<std::array<int, 2>> adj[1000];
ll dist[1000];
bool ex[1000];

void dfs(int i, int p){
	for(const auto &[x, d] : adj[i]) if(x != p) dfs(x, i);

	ll best[2] = {1ll<<61, 1ll<<61};

	for(const auto &[x, d] : adj[i]) if(x != p){
		ll cons = dist[x] + d;
		if(cons < best[0]) best[0] = cons;
		if(best[0] < best[1]) std::swap(best[0], best[1]);
	}

	if(!ex[i]) dist[i] = best[0];
}

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){
	for(int i=0; i<m; ++i){
		adj[r[i][0]].push_back({r[i][1], l[i]});
		adj[r[i][1]].push_back({r[i][0], l[i]});
	}

	for(int i=0; i<k; ++i) ex[p[i]] = 1;
	
	dfs(0, -1);

	return dist[0];
}

詳細信息

Subtask #1:

score: 46
Accepted

Test #1:

score: 46
Accepted
time: 1ms
memory: 5936kb

input:

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

output:

Correct.

Test #2:

score: 46
Accepted
time: 0ms
memory: 5820kb

input:

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

output:

Correct.

Test #3:

score: 46
Accepted
time: 1ms
memory: 7944kb

input:

364 363 243
0 1 5467
0 2 7494
0 3 7866
1 4 8712
1 5 4222
1 6 965
2 7 2548
2 8 7874
2 9 7495
3 10 5689
3 11 8312
3 12 8017
4 13 3772
4 14 6137
4 15 6369
5 16 3140
5 17 3172
5 18 1095
6 19 2911
6 20 5370
6 21 9527
7 22 5740
7 23 934
7 24 7533
8 25 8764
8 26 4750
8 27 2730
9 28 374
9 29 7116
9 30 5429
...

output:

Correct.

Test #4:

score: 46
Accepted
time: 1ms
memory: 5932kb

input:

999 998 593
159 274 73
156 723 72
252 910 28
725 444 43
727 312 34
588 958 24
304 386 76
35 912 84
428 540 59
447 492 21
785 711 88
328 77 20
810 573 55
582 219 15
624 979 54
790 48 97
100 987 44
851 405 43
975 313 29
130 766 39
592 755 85
796 928 41
739 97 33
958 914 25
409 844 82
306 552 99
124 43...

output:

Correct.

Test #5:

score: 46
Accepted
time: 0ms
memory: 8028kb

input:

1000 999 752
986 658 8
655 441 6
181 302 1
52 534 4
424 122 1
271 997 9
654 724 2
899 732 9
53 689 8
920 349 2
657 946 10
622 851 4
287 732 8
249 488 10
39 374 2
327 493 3
229 105 5
192 468 7
451 24 3
873 618 5
879 861 2
740 509 10
205 118 4
336 362 8
302 859 10
959 649 9
543 161 6
661 645 2
733 365...

output:

Correct.

Test #6:

score: 46
Accepted
time: 1ms
memory: 5904kb

input:

700 699 496
364 265 3
543 594 3
413 246 1
638 560 3
555 181 2
189 191 3
565 319 1
531 573 3
5 77 2
592 88 1
54 316 4
50 370 2
402 547 1
440 625 4
154 458 2
152 151 3
257 376 1
462 52 1
375 459 4
153 224 2
256 456 2
129 177 2
214 118 2
608 281 4
453 320 3
153 635 2
546 59 4
305 672 2
497 392 3
120 47...

output:

Correct.

Test #7:

score: 46
Accepted
time: 1ms
memory: 5956kb

input:

999 998 599
469 659 5837
285 544 5302
212 813 5377
156 277 5805
475 661 103
843 959 2724
510 255 1426
466 720 6575
106 191 3031
745 483 3212
489 338 2682
95 462 3865
749 853 2316
336 730 2080
513 845 2679
133 681 9520
545 352 7496
839 332 629
959 709 6931
212 435 4277
94 626 3032
901 894 205
305 805...

output:

Correct.

Test #8:

score: 46
Accepted
time: 0ms
memory: 5900kb

input:

1000 999 501
89 28 1
647 192 1
304 141 1
938 27 1
753 516 1
605 515 1
256 101 1
425 171 1
843 325 1262
534 54 1
113 289 1826
143 124 1614
816 345 1
645 931 1
854 157 1
878 990 1
164 428 1720
0 96 1
956 470 1
692 901 1290
825 988 1
844 875 1
996 979 1
32 239 1652
953 924 1
293 411 1
935 469 1476
93 1...

output:

Correct.

Subtask #2:

score: 0
Memory Limit Exceeded

Test #9:

score: 0
Memory Limit Exceeded

input:

180 5000 50
0 1 5056
1 2 5206
2 3 2716
3 4 6462
4 5 9699
5 6 748
6 7 8064
7 8 9906
8 9 5710
9 10 7776
10 11 8981
11 12 5351
12 13 7603
13 14 7860
14 15 6117
15 16 5350
16 17 2074
17 18 2448
18 19 4300
19 20 8707
20 21 3075
21 22 1227
22 23 7738
23 24 2987
24 25 5700
25 26 7985
26 27 9954
27 28 4165
...

output:

Unauthorized output

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%