QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#110249#2004. Crocodile's Underground Cityminhcool#100 ✓279ms87448kbC++201.8kb2023-06-01 09:04:332024-05-31 13:52:49

Judging History

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

  • [2024-05-31 13:52:49]
  • 评测
  • 测评结果:100
  • 用时:279ms
  • 内存:87448kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-01 09:04:33]
  • 提交

answer

#include "crocodile.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef pair<ii, ii> iiii;

const ll N = 3e5 + 5;

const ll oo = 1e18 + 7, mod = 1e9 + 7;

mt19937 rng(1);

ll rnd(ll l, ll r){
	ll temp = rng() % (r - l + 1);
	return abs(temp) + l;
}

ll n, m, k;

vector<ii> Adj[N];

iiii cals[N];
//set<ii> cals[N];

bool ck[N];

ll mn_dist[N];

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
	n = N, m = M, k = K;
	for(int i = 0; i < m; i++){
		Adj[R[i][0]].pb({R[i][1], L[i]});
		Adj[R[i][1]].pb({R[i][0], L[i]});		
	}
	priority_queue<ii, vector<ii>, greater<ii>> pq;
	for(int i = 0; i < n; i++){
		mn_dist[i] = oo;
		cals[i] = {{oo, oo}, {oo, oo}};
	}
	for(int i = 0; i < k; i++){
		ck[P[i]] = 1;
		mn_dist[P[i]] = 0;
		pq.push({0, P[i]});
	}
	while(!pq.empty()){
		int d = pq.top().fi, u = pq.top().se;
		//cout << d << " " << u << "\n";
		pq.pop();
		if(mn_dist[u] != d) continue;
		for(auto it : Adj[u]){
			int v = it.fi, w = it.se;
			ii temp = {mn_dist[u] + w, u};
			if(temp <= cals[v].fi){
				cals[v] = {temp, cals[v].fi};
			}
			else if(temp <= cals[v].se) cals[v] = {cals[v].fi, temp};
			//cals[v].insert({mn_dist[u] + w, u});
			if(cals[v].se.fi != oo){
				//set<ii>::iterator it = cals[v].begin();
				//it++;
				if(mn_dist[v] > cals[v].se.fi){
					mn_dist[v] = cals[v].se.fi;
					pq.push({mn_dist[v], v});
				}
			}
		}
	}
	return (mn_dist[0] == oo ? -1 : mn_dist[0]);
}

/*
void process(){

}

signed main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	process();
}
*/

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 46
Accepted

Test #1:

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

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: 0
Accepted
time: 2ms
memory: 9932kb

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: 0
Accepted
time: 0ms
memory: 9896kb

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: 0
Accepted
time: 0ms
memory: 12084kb

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: 0
Accepted
time: 2ms
memory: 10004kb

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: 0
Accepted
time: 2ms
memory: 10240kb

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: 0
Accepted
time: 0ms
memory: 9976kb

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: 0
Accepted
time: 0ms
memory: 12032kb

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: 43
Accepted

Test #9:

score: 43
Accepted
time: 0ms
memory: 10216kb

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:

Correct.

Test #10:

score: 0
Accepted
time: 2ms
memory: 9948kb

input:

200 396 2
0 1 1974
0 100 8166
199 1 9339
199 100 3816
1 2 2411
1 101 7482
100 2 8069
100 101 6844
2 3 2101
2 102 118
101 3 4364
101 102 9370
3 4 5039
3 103 5457
102 4 9281
102 103 5121
4 5 1620
4 104 964
103 5 3350
103 104 8929
5 6 388
5 105 465
104 6 1472
104 105 6174
6 7 9351
6 106 999
105 7 6793
...

output:

Correct.

Test #11:

score: 0
Accepted
time: 0ms
memory: 10008kb

input:

200 2100 2
0 1 6498
0 100 2987
199 1 9302
199 100 1327
1 2 1452
1 101 2834
100 2 1772
100 101 1303
2 3 7485
2 102 4416
101 3 2081
101 102 9954
3 4 9234
3 103 720
102 4 9460
102 103 9173
4 5 7500
4 104 2565
103 5 5766
103 104 2544
5 6 1815
5 105 3056
104 6 4656
104 105 2178
6 7 4064
6 106 6413
105 7 ...

output:

Correct.

Test #12:

score: 0
Accepted
time: 4ms
memory: 12460kb

input:

200 10000 2
0 1 229
0 100 5360
199 1 4076
199 100 6076
1 2 8251
1 101 3051
100 2 4789
100 101 532
2 3 6337
2 102 9468
101 3 9777
101 102 8975
3 4 936
3 103 7972
102 4 127
102 103 1971
4 5 9933
4 104 6489
103 5 6918
103 104 9162
5 6 2167
5 105 3527
104 6 5143
104 105 1249
6 7 8291
6 106 7394
105 7 13...

output:

Correct.

Test #13:

score: 0
Accepted
time: 3ms
memory: 10488kb

input:

141 9870 2
0 1 1
0 2 3
0 3 5
0 4 7
0 5 9
0 6 11
0 7 13
0 8 15
0 9 17
0 10 19
0 11 21
0 12 23
0 13 25
0 14 27
0 15 29
0 16 31
0 17 33
0 18 35
0 19 37
0 20 39
0 21 41
0 22 43
0 23 45
0 24 47
0 25 49
0 26 51
0 27 53
0 28 55
0 29 57
0 30 59
0 31 61
0 32 63
0 33 65
0 34 67
0 35 69
0 36 71
0 37 73
0 38 75...

output:

Correct.

Test #14:

score: 0
Accepted
time: 2ms
memory: 10220kb

input:

200 598 10
0 1 628
0 2 4137
0 3 5331
0 4 9253
0 5 4534
0 6 1930
0 7 6241
0 8 2194
0 9 5612
0 10 6302
0 11 5364
0 12 4481
0 13 5120
0 14 481
0 15 1539
0 16 4582
0 17 4996
0 18 7806
0 19 8954
0 20 8214
0 21 6733
1 24 3176
1 31 3223
1 25 4526
2 39 3847
2 42 2814
2 33 825
3 42 1028
3 41 1269
3 38 2617
4...

output:

Correct.

Test #15:

score: 0
Accepted
time: 0ms
memory: 9984kb

input:

200 1909 9
0 1 7572
0 2 8230
0 3 1247
0 4 7512
0 5 4617
0 6 8057
0 7 5724
0 8 4592
0 9 2366
0 10 8218
1 14 5148
1 12 5736
1 13 252
1 11 3356
1 15 8070
1 19 3797
1 17 6173
1 16 1301
1 18 1125
1 20 1818
2 16 4069
2 17 2315
2 14 1813
2 11 6776
2 13 9906
2 12 7767
2 20 5721
2 15 4575
2 18 6615
2 19 9271...

output:

Correct.

Subtask #3:

score: 11
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #16:

score: 11
Accepted
time: 223ms
memory: 77576kb

input:

40000 1000000 600
0 1 5403
1 2 7808
2 3 7629
3 4 4651
4 5 6251
5 6 9155
6 7 6843
7 8 1433
8 9 392
9 10 4328
10 11 2029
11 12 2681
12 13 4640
13 14 6944
14 15 1778
15 16 1382
16 17 6389
17 18 2394
18 19 982
19 20 499
20 21 6808
21 22 5626
22 23 5248
23 24 2983
24 25 4894
25 26 848
26 27 583
27 28 225...

output:

Correct.

Test #17:

score: 0
Accepted
time: 19ms
memory: 28868kb

input:

100000 199996 2
0 1 1768
0 50000 3107
99999 1 6207
99999 50000 1910
1 2 711
1 50001 8149
50000 2 9269
50000 50001 8345
2 3 8094
2 50002 4120
50001 3 2392
50001 50002 553
3 4 9323
3 50003 6913
50002 4 1418
50002 50003 5919
4 5 8052
4 50004 1182
50003 5 1586
50003 50004 5927
5 6 8973
5 50005 7810
5000...

output:

Correct.

Test #18:

score: 0
Accepted
time: 54ms
memory: 28604kb

input:

100000 210000 2
0 1 9514
0 50000 9412
99999 1 5308
99999 50000 3801
1 2 7760
1 50001 5779
50000 2 777
50000 50001 6496
2 3 9041
2 50002 5682
50001 3 9941
50001 50002 6829
3 4 3779
3 50003 4412
50002 4 8939
50002 50003 3226
4 5 6221
4 50004 7113
50003 5 9004
50003 50004 9415
5 6 9104
5 50005 630
5000...

output:

Correct.

Test #19:

score: 0
Accepted
time: 279ms
memory: 87448kb

input:

100000 1000000 2
0 1 5250
0 50000 2509
99999 1 6512
99999 50000 9692
1 2 5320
1 50001 1236
50000 2 8470
50000 50001 1929
2 3 3182
2 50002 3404
50001 3 951
50001 50002 3816
3 4 5096
3 50003 687
50002 4 9073
50002 50003 2572
4 5 6156
4 50004 818
50003 5 3939
50003 50004 2328
5 6 4956
5 50005 3717
5000...

output:

Correct.

Test #20:

score: 0
Accepted
time: 131ms
memory: 59960kb

input:

1414 998991 2
0 1 1
0 2 3
0 3 5
0 4 7
0 5 9
0 6 11
0 7 13
0 8 15
0 9 17
0 10 19
0 11 21
0 12 23
0 13 25
0 14 27
0 15 29
0 16 31
0 17 33
0 18 35
0 19 37
0 20 39
0 21 41
0 22 43
0 23 45
0 24 47
0 25 49
0 26 51
0 27 53
0 28 55
0 29 57
0 30 59
0 31 61
0 32 63
0 33 65
0 34 67
0 35 69
0 36 71
0 37 73
0 38...

output:

Correct.

Test #21:

score: 0
Accepted
time: 24ms
memory: 19340kb

input:

30000 89989 9
0 1 2327
0 2 9491
0 3 9954
0 4 4610
0 5 3317
0 6 1449
0 7 5672
0 8 1007
0 9 1028
0 10 7996
1 19 9967
1 15 4726
1 17 8396
2 16 9307
2 20 5774
2 15 2421
3 17 2643
3 11 6262
3 20 8324
4 15 5021
4 20 6655
4 13 6230
5 13 8242
5 12 3960
5 19 3606
6 11 2192
6 16 165
6 13 6910
7 19 3788
7 20 6...

output:

Correct.

Test #22:

score: 0
Accepted
time: 158ms
memory: 57280kb

input:

30000 897199 99
0 1 8460
0 2 1033
0 3 4697
0 4 1122
0 5 7581
0 6 1283
0 7 1225
0 8 1436
0 9 9639
0 10 5531
0 11 595
0 12 5602
0 13 1155
0 14 357
0 15 5069
0 16 2974
0 17 483
0 18 2229
0 19 7046
0 20 7943
0 21 2228
0 22 3709
0 23 5119
0 24 5579
0 25 6404
0 26 8344
0 27 3355
0 28 7503
0 29 1798
0 30 2...

output:

Correct.