CSES - IZhO 2018, day 1 - Results
Submission details
Task:Evacuation plan
Sender:henrikaalto
Submission time:2019-02-14 20:16:50 +0200
Language:C++
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
#40
#50
Test results
testverdicttimegroup
#10.02 s3, 5details
#20.02 s1, 2, 3, 5details
#30.02 s1, 2, 5details
#40.02 s1, 2, 5details
#50.03 s1, 2, 3, 5details
#60.02 s1, 2, 5details
#70.02 s1, 2, 5details
#80.02 s1, 2, 5details
#90.02 s1, 2, 5details
#100.02 s1, 2, 5details
#110.02 s1, 2, 5details
#120.01 s1, 2, 5details
#130.02 s1, 2, 5details
#140.02 s1, 2, 5details
#150.02 s1, 2, 5details
#160.02 s1, 2, 5details
#170.12 s2, 5details
#180.42 s2, 5details
#190.05 s2, 5details
#200.11 s2, 5details
#210.44 s2, 5details
#220.23 s2, 5details
#230.10 s2, 5details
#240.43 s2, 5details
#250.42 s2, 5details
#260.42 s2, 5details
#270.12 s2, 5details
#280.11 s2, 5details
#290.11 s2, 5details
#300.12 s2, 5details
#310.12 s2, 5details
#320.03 s3, 5details
#330.02 s3, 5details
#340.02 s3, 5details
#350.01 s3, 5details
#360.02 s3, 5details
#370.02 s3, 5details
#380.03 s3, 5details
#390.01 s3, 5details
#400.03 s3, 5details
#410.03 s3, 5details
#420.21 s4, 5details
#430.48 s4, 5details
#440.45 s4, 5details
#45ACCEPTED0.11 s4, 5details
#46ACCEPTED0.43 s4, 5details
#470.42 s4, 5details
#480.42 s4, 5details
#490.41 s4, 5details
#500.42 s4, 5details
#510.41 s4, 5details
#520.40 s4, 5details
#530.42 s4, 5details
#540.41 s4, 5details
#550.41 s4, 5details
#560.42 s4, 5details
#570.42 s4, 5details
#580.41 s4, 5details
#590.45 s4, 5details
#60ACCEPTED0.10 s2, 4, 5details
#610.41 s4, 5details
#62ACCEPTED0.42 s4, 5details
#63ACCEPTED0.11 s4, 5details
#64ACCEPTED0.10 s4, 5details
#65ACCEPTED0.11 s4, 5details
#66ACCEPTED0.12 s4, 5details
#67ACCEPTED0.12 s4, 5details
#68ACCEPTED0.12 s4, 5details
#69ACCEPTED0.11 s4, 5details
#70ACCEPTED0.11 s4, 5details
#71ACCEPTED0.11 s4, 5details
#72ACCEPTED0.12 s4, 5details
#730.24 s5details
#740.42 s5details
#750.43 s5details
#760.42 s5details
#770.41 s5details
#780.43 s5details
#790.42 s5details
#800.42 s5details
#810.42 s5details
#820.44 s5details
#830.41 s5details
#840.41 s5details
#850.42 s5details
#860.41 s5details
#870.42 s5details
#880.41 s5details
#890.43 s5details
#900.11 s5details
#910.42 s5details
#920.43 s5details
#930.12 s5details
#940.11 s5details
#950.11 s5details
#960.11 s5details
#970.11 s5details
#980.12 s5details
#990.12 s5details
#1000.13 s5details
#1010.11 s5details

Code

#include<bits/stdc++.h>
#define N (1<<17)
using namespace std;
typedef long long ll;
ll dist[N];
bool prc[N][2];
vector<pair<int,int>> adj[N];
bool NPP[N];
#define f first
#define s second

void dfs(int x,int i,ll curr){
  if(prc[x][i])return;
  prc[x][i]=1;
  for(auto u:adj[x]){
    if(!i){
      if(curr+u.s==dist[u.f])
        dfs(u.f,i,curr+u.s);
    }
    else{
      if(curr-u.s==dist[u.f])
        dfs(u.f,i,curr-u.s);
    }
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  int n,m,a,b,c;
  cin>>n>>m;
  for(int i=1;i<=m;i++){
    cin>>a>>b>>c;
    adj[a].push_back({b,c});
    adj[b].push_back({a,c});
  }
  for(int i=1;i<=n;i++) dist[i]=INT64_MAX;
  int temp; cin>>temp;
  for(int i=1;i<=temp;i++){
    int x; cin>>x;
    NPP[x]=1;
  }
  cin>>temp;
  cin>>a>>b;

  dist[a]=0;
  priority_queue<pair<ll,int>> q;
  q.push({0,a});
  while(!q.empty()){
    int a=q.top().s;q.pop();
    if(prc[a][0]) continue;
    prc[a][0]=1;
    for(auto u:adj[a]){
      int b=u.f,w=u.s;
      if(dist[a]+w<dist[b]){
        dist[b]=dist[a]+w;
        q.push({-dist[b],b});
      }
    }
  }
  vector<int> v;
  for(int i=1;i<=n;i++) prc[i][0]=prc[i][1]=0;
  dfs(a,0,0);
  dfs(b,1,dist[b]);
  for(int i=1;i<=n;i++) dist[i]=1e18;
  for(int i=1;i<=n;i++)
    if(prc[i][0] && prc[i][1])
      q.push({0,i}),dist[i]=0;

  for(int i=1;i<=n;i++) prc[i][0]=0;
  while(!q.empty()){
    int a=q.top().s;
    ll c=q.top().f;
    q.pop();
    if(prc[a][0]) continue;
    prc[a][0]=1;
    if(NPP[a]){
      cout<<-c<<"\n";
      return 0;
    }
    for(auto u:adj[a]){
      int b=u.f,w=u.s;
      if(dist[a]+w<dist[b]){
        dist[b]=dist[a]+w;
        q.push({-dist[b],b});
      }
    }
  }
}

Test details

Test 1

Group: 3, 5

Verdict:

input
9 12
1 9 4
1 2 5
2 3 7
2 4 3
...

correct output
5
5
0
7
8

user output
5

Test 2

Group: 1, 2, 3, 5

Verdict:

input
10 20
1 2 657
1 3 522
1 4 448
3 5 855
...

correct output
0
408
541
541
432
...

user output
0

Test 3

Group: 1, 2, 5

Verdict:

input
1000 999
588 473 61
588 91 30
588 75 125
588 980 551
...

correct output
552
552
552
552
552
...

user output
552

Test 4

Group: 1, 2, 5

Verdict:

input
1000 999
975 859 302
975 422 394
975 634 444
975 439 384
...

correct output
37
37
37
37
37
...

user output
37

Test 5

Group: 1, 2, 3, 5

Verdict:

input
10 9
7 3 759
7 2 864
7 5 89
7 10 855
...

correct output
491
491
491
0
491
...

user output
491

Test 6

Group: 1, 2, 5

Verdict:

input
1000 999
585 395 355
585 651 77
585 728 215
585 392 955
...

correct output
6
6
6
6
6
...

user output
6

Test 7

Group: 1, 2, 5

Verdict:

input
1000 999
986 358 7
986 142 732
986 586 346
986 193 901
...

correct output
0
0
0
0
0
...

user output
0

Test 8

Group: 1, 2, 5

Verdict:

input
100 200
1 2 828
1 3 496
1 4 331
2 5 347
...

correct output
0
0
0
0
0
...

user output
0

Test 9

Group: 1, 2, 5

Verdict:

input
100 200
1 2 333
2 3 309
3 4 901
1 5 429
...

correct output
0
0
0
0
0
...

user output
0

Test 10

Group: 1, 2, 5

Verdict:

input
1000 1000
1 2 980
2 3 726
3 4 888
4 5 810
...

correct output
2768
3408
4109
5400
2412
...

user output
2768

Test 11

Group: 1, 2, 5

Verdict:

input
1000 1000
1 2 353
1 3 672
3 4 861
4 5 517
...

correct output
0
0
0
0
0
...

user output
0

Test 12

Group: 1, 2, 5

Verdict:

input
1000 1000
1 2 127
2 3 854
1 4 813
4 5 8
...

correct output
3925
2711
2047
2304
1751
...

user output
3925

Test 13

Group: 1, 2, 5

Verdict:

input
1000 999
340 299 654
340 911 553
340 232 256
340 761 558
...

correct output
226
226
226
226
226
...

user output
226

Test 14

Group: 1, 2, 5

Verdict:

input
1000 1000
1 2 188
2 3 247
3 4 641
2 5 473
...

correct output
638
863
441
0
976
...

user output
638

Test 15

Group: 1, 2, 5

Verdict:

input
1000 1000
1 2 393
2 3 682
2 4 841
1 5 84
...

correct output
5609
6225
5028
3588
4348
...

user output
5609

Test 16

Group: 1, 2, 5

Verdict:

input
1000 1000
1 2 569
1 3 813
2 4 461
4 5 493
...

correct output
5350
2221
1313
3010
3983
...

user output
5350

Test 17

Group: 2, 5

Verdict:

input
77777 99999
1 2 891
2 3 879
3 4 604
4 5 254
...

correct output
4493
3124
3584
4203
3352
...

user output
4493

Test 18

Group: 2, 5

Verdict:

input
100000 500000
1 2 13
1 3 882
3 4 392
2 5 498
...

correct output
852
901
1120
1165
1239
...

user output
852

Test 19

Group: 2, 5

Verdict:

input
12321 41332
1 2 81
2 3 165
3 4 941
2 5 167
...

correct output
1270
1486
1185
1113
1222
...

user output
1270

Test 20

Group: 2, 5

Verdict:

input
100000 99999
38940 18613 406
38940 77994 688
38940 1918 847
38940 33444 215
...

correct output
104
104
104
104
104
...

user output
104

Test 21

Group: 2, 5

Verdict:

input
100000 500000
1 2 461
2 3 439
2 4 578
3 5 317
...

correct output
1097
717
1251
955
1045
...

user output
1097

Test 22

Group: 2, 5

Verdict:

input
100000 200000
1 2 984
1 3 96
1 4 469
3 5 480
...

correct output
323
0
156
79
0
...

user output
323

Test 23

Group: 2, 5

Verdict:

input
100000 99999
86937 75997 956
75997 86103 901
86103 13024 918
13024 85212 947
...

correct output
29396767
21591510
55276964
33539480
72080903
...

user output
29396767

Test 24

Group: 2, 5

Verdict:

input
100000 500000
1 2 761
1 3 820
3 4 219
4 5 989
...

correct output
970
711
780
699
716
...

user output
970

Test 25

Group: 2, 5

Verdict:

input
100000 500000
1 2 697
2 3 846
1 4 365
4 5 576
...

correct output
355
625
766
605
583
...

user output
355

Test 26

Group: 2, 5

Verdict:

input
100000 500000
1 2 295
2 3 254
2 4 820
1 5 418
...

correct output
55
371
0
341
0
...

user output
55

Test 27

Group: 2, 5

Verdict:

input
100000 99999
60099 24766 247
60099 62884 191
60099 59379 971
60099 30532 420
...

correct output
1
1
1
1
1
...

user output
1

Test 28

Group: 2, 5

Verdict:

input
100000 99999
49317 55052 770
49317 54295 838
49317 44228 765
49317 97326 531
...

correct output
35
35
35
35
35
...

user output
35

Test 29

Group: 2, 5

Verdict:

input
100000 99999
12914 47476 547
12914 96120 727
12914 44181 338
12914 36309 794
...

correct output
6
6
6
6
6
...

user output
6

Test 30

Group: 2, 5

Verdict:

input
100000 99999
49333 95815 271
49333 26107 718
49333 43319 270
49333 41236 458
...

correct output
62
62
62
62
62
...

user output
62

Test 31

Group: 2, 5

Verdict:

input
100000 99999
35081 4986 303
35081 4729 336
35081 7666 670
35081 28578 508
...

correct output
257
257
257
257
257
...

user output
257

Test 32

Group: 3, 5

Verdict:

input
15 20
1 2 429
2 3 101
3 4 174
4 5 733
...

correct output
226
416
325
325
416
...

user output
226

Test 33

Group: 3, 5

Verdict:

input
15 25
1 2 906
2 3 853
1 4 546
3 5 623
...

correct output
295
295
0
0
794
...

user output
228

Test 34

Group: 3, 5

Verdict:

input
15 40
1 2 406
2 3 911
1 4 725
2 5 482
...

correct output
190
406
0
0
190
...

user output
0

Test 35

Group: 3, 5

Verdict:

input
15 70
1 2 732
2 3 729
3 4 174
1 5 417
...

correct output
61
108
149
61
0
...

user output
0

Test 36

Group: 3, 5

Verdict:

input
15 100
1 2 186
1 3 309
3 4 38
3 5 229
...

correct output
38
49
0
0
0
...

user output
0

Test 37

Group: 3, 5

Verdict:

input
15 100
1 2 46
1 3 998
1 4 524
1 5 42
...

correct output
0
0
66
68
78
...

user output
0

Test 38

Group: 3, 5

Verdict:

input
15 89
1 2 590
1 3 542
2 4 430
3 5 13
...

correct output
0
0
0
0
0
...

user output
0

Test 39

Group: 3, 5

Verdict:

input
15 14
1 2 738
1 3 739
3 4 465
1 5 134
...

correct output
0
0
0
0
0
...

user output
0

Test 40

Group: 3, 5

Verdict:

input
15 14
15 8 438
15 11 672
15 12 20
15 7 752
...

correct output
0
0
0
0
0
...

user output
0

Test 41

Group: 3, 5

Verdict:

input
15 100
1 2 451
1 3 701
1 4 637
1 5 547
...

correct output
164
158
0
152
117
...

user output
126

Test 42

Group: 4, 5

Verdict:

input
100000 200000
1 2 931
2 3 916
1 4 342
2 5 18
...

correct output
2782

user output
1504

Test 43

Group: 4, 5

Verdict:

input
100000 500000
1 2 485
1 3 567
2 4 479
1 5 166
...

correct output
1480

user output
1267

Test 44

Group: 4, 5

Verdict:

input
100000 500000
1 2 129
2 3 866
1 4 165
1 5 254
...

correct output
1084

user output
911

Test 45

Group: 4, 5

Verdict: ACCEPTED

input
100000 99999
55393 66829 903
66829 72184 985
72184 47162 950
47162 22279 989
...

correct output
0

user output
0

Test 46

Group: 4, 5

Verdict: ACCEPTED

input
100000 500000
1 2 783
2 3 877
2 4 834
1 5 734
...

correct output
557

user output
557

Test 47

Group: 4, 5

Verdict:

input
100000 500000
1 2 817
1 3 411
1 4 947
2 5 943
...

correct output
794

user output
705

Test 48

Group: 4, 5

Verdict:

input
100000 500000
1 2 212
1 3 723
1 4 614
4 5 819
...

correct output
712

user output
314

Test 49

Group: 4, 5

Verdict:

input
100000 500000
1 2 203
2 3 684
2 4 766
3 5 287
...

correct output
879

user output
556

Test 50

Group: 4, 5

Verdict:

input
100000 500000
1 2 879
2 3 322
3 4 851
3 5 348
...

correct output
950

user output
639

Test 51

Group: 4, 5

Verdict:

input
100000 500000
1 2 36
1 3 883
2 4 519
3 5 579
...

correct output
837

user output
443

Test 52

Group: 4, 5

Verdict:

input
100000 500000
1 2 1000
1 3 207
1 4 668
4 5 272
...

correct output
499

user output
443

Test 53

Group: 4, 5

Verdict:

input
100000 500000
1 2 991
1 3 104
1 4 717
4 5 165
...

correct output
447

user output
259

Test 54

Group: 4, 5

Verdict:

input
100000 500000
1 2 803
1 3 429
3 4 634
4 5 99
...

correct output
315

user output
0

Test 55

Group: 4, 5

Verdict:

input
100000 500000
1 2 33
1 3 661
1 4 630
3 5 685
...

correct output
350

user output
203

Test 56

Group: 4, 5

Verdict:

input
100000 500000
1 2 636
2 3 716
1 4 58
2 5 337
...

correct output
50

user output
0

Test 57

Group: 4, 5

Verdict:

input
100000 500000
1 2 294
2 3 768
1 4 524
1 5 307
...

correct output
366

user output
317

Test 58

Group: 4, 5

Verdict:

input
100000 500000
1 2 87
1 3 998
3 4 888
4 5 103
...

correct output
759

user output
591

Test 59

Group: 4, 5

Verdict:

input
100000 500000
1 2 176
2 3 314
3 4 513
2 5 686
...

correct output
1222

user output
960

Test 60

Group: 2, 4, 5

Verdict: ACCEPTED

input
100000 99999
62990 65315 931
65315 3455 970
3455 98310 995
98310 23065 952
...

correct output
95052504

user output
95052504

Test 61

Group: 4, 5

Verdict:

input
100000 500000
1 2 585
2 3 805
3 4 581
1 5 572
...

correct output
800

user output
551

Test 62

Group: 4, 5

Verdict: ACCEPTED

input
100000 500000
1 2 150
1 3 624
3 4 361
1 5 742
...

correct output
0

user output
0

Test 63

Group: 4, 5

Verdict: ACCEPTED

input
100000 99999
42321 26741 992
42321 69329 304
42321 5758 819
42321 29266 648
...

correct output
111

user output
111

Test 64

Group: 4, 5

Verdict: ACCEPTED

input
100000 100000
51519 55325 253
55325 18282 583
18282 90551 470
90551 91972 266
...

correct output
1057897

user output
1057897

Test 65

Group: 4, 5

Verdict: ACCEPTED

input
100000 99999
54801 39194 733
54801 39401 162
54801 65113 479
54801 61590 30
...

correct output
3

user output
3

Test 66

Group: 4, 5

Verdict: ACCEPTED

input
100000 99999
15780 41412 52
15780 99212 342
15780 8094 961
15780 33547 16
...

correct output
19

user output
19

Test 67

Group: 4, 5

Verdict: ACCEPTED

input
100000 100000
76627 21712 427
21712 26993 256
26993 80393 100
80393 56194 44
...

correct output
0

user output
0

Test 68

Group: 4, 5

Verdict: ACCEPTED

input
100000 99999
88549 9364 973
9364 6403 998
6403 29693 969
29693 59321 938
...

correct output
0

user output
0

Test 69

Group: 4, 5

Verdict: ACCEPTED

input
100000 99999
60084 18317 681
60084 77472 797
60084 93299 190
60084 76120 745
...

correct output
1

user output
1

Test 70

Group: 4, 5

Verdict: ACCEPTED

input
100000 99999
67813 44109 993
44109 32579 980
32579 83236 911
83236 58703 958
...

correct output
0

user output
0

Test 71

Group: 4, 5

Verdict: ACCEPTED

input
100000 99999
99416 74269 87
99416 87958 424
99416 43397 39
99416 62377 783
...

correct output
1

user output
1

Test 72

Group: 4, 5

Verdict: ACCEPTED

input
100000 99999
80340 75986 985
75986 12073 987
12073 14775 998
14775 51604 912
...

correct output
0

user output
0

Test 73

Group: 5

Verdict:

input
100000 200000
1 2 641
2 3 327
2 4 612
3 5 929
...

correct output
2789
2693
2317
2490
2585
...

user output
2659

Test 74

Group: 5

Verdict:

input
100000 500000
1 2 423
1 3 258
3 4 573
2 5 503
...

correct output
943
879
757
840
810
...

user output
648

Test 75

Group: 5

Verdict:

input
100000 500000
1 2 696
2 3 91
1 4 594
1 5 389
...

correct output
928
915
909
978
302
...

user output
838

Test 76

Group: 5

Verdict:

input
100000 500000
1 2 839
1 3 344
1 4 742
3 5 969
...

correct output
741
1036
993
553
1057
...

user output
591

Test 77

Group: 5

Verdict:

input
100000 500000
1 2 451
1 3 46
3 4 291
4 5 937
...

correct output
876
692
608
407
459
...

user output
565

Test 78

Group: 5

Verdict:

input
100000 500000
1 2 750
1 3 891
2 4 533
1 5 421
...

correct output
662
632
594
622
601
...

user output
662

Test 79

Group: 5

Verdict:

input
100000 500000
1 2 300
2 3 460
3 4 834
3 5 381
...

correct output
594
954
739
873
953
...

user output
439

Test 80

Group: 5

Verdict:

input
100000 500000
1 2 311
1 3 228
2 4 42
3 5 981
...

correct output
596
977
754
830
731
...

user output
590

Test 81

Group: 5

Verdict:

input
100000 500000
1 2 655
1 3 626
1 4 92
1 5 719
...

correct output
588
957
831
766
558
...

user output
588

Test 82

Group: 5

Verdict:

input
100000 500000
1 2 241
2 3 717
2 4 756
4 5 555
...

correct output
1077
655
838
981
1077
...

user output
898

Test 83

Group: 5

Verdict:

input
100000 500000
1 2 22
2 3 950
2 4 300
2 5 192
...

correct output
457
426
389
460
518
...

user output
314

Test 84

Group: 5

Verdict:

input
100000 500000
1 2 235
1 3 508
3 4 611
1 5 468
...

correct output
215
458
591
147
495
...

user output
0

Test 85

Group: 5

Verdict:

input
100000 500000
1 2 203
1 3 412
3 4 390
2 5 433
...

correct output
215
314
284
413
301
...

user output
0

Test 86

Group: 5

Verdict:

input
100000 500000
1 2 427
2 3 613
1 4 102
1 5 320
...

correct output
171
16
110
184
63
...

user output
71

Test 87

Group: 5

Verdict:

input
100000 500000
1 2 738
2 3 891
3 4 468
4 5 717
...

correct output
505
51
370
297
108
...

user output
348

Test 88

Group: 5

Verdict:

input
100000 500000
1 2 552
2 3 990
1 4 264
3 5 715
...

correct output
589
751
640
868
540
...

user output
279

Test 89

Group: 5

Verdict:

input
100000 500000
1 2 928
2 3 476
3 4 531
4 5 166
...

correct output
1015
996
1150
995
1045
...

user output
929

Test 90

Group: 5

Verdict:

input
100000 99999
92489 77658 971
77658 44038 908
44038 16706 947
16706 86719 936
...

correct output
95057187
21105802
9382625
33465301
45188238
...

user output
95057187

Test 91

Group: 5

Verdict:

input
100000 500000
1 2 499
2 3 548
1 4 153
3 5 7
...

correct output
978
983
634
768
627
...

user output
822

Test 92

Group: 5

Verdict:

input
100000 500000
1 2 663
1 3 944
1 4 67
1 5 976
...

correct output
0
0
0
0
0
...

user output
0

Test 93

Group: 5

Verdict:

input
100000 99999
12420 1528 466
12420 42872 479
12420 8461 723
12420 75677 717
...

correct output
55
55
55
55
55
...

user output
55

Test 94

Group: 5

Verdict:

input
100000 100000
55076 46178 852
46178 35188 936
35188 36448 616
36448 20101 711
...

correct output
405459
1058750
3569995
3807
2822955
...

user output
6687

Test 95

Group: 5

Verdict:

input
100000 99999
86054 48657 652
86054 68231 412
86054 29096 379
86054 59437 691
...

correct output
1
1
1
1
1
...

user output
1

Test 96

Group: 5

Verdict:

input
100000 99999
39950 45152 493
39950 48400 664
39950 31284 726
39950 86952 141
...

correct output
14
14
14
14
14
...

user output
14

Test 97

Group: 5

Verdict:

input
100000 100000
12935 19528 317
19528 89291 248
89291 70689 378
70689 6165 906
...

correct output
1087
0
0
0
159917
...

user output
1087

Test 98

Group: 5

Verdict:

input
100000 99999
40231 61273 959
61273 21887 924
21887 63910 986
63910 64968 933
...

correct output
0
6434711
9195470
0
0
...

user output
0

Test 99

Group: 5

Verdict:

input
100000 99999
74744 3772 134
74744 37184 823
74744 15444 783
74744 96445 78
...

correct output
2
2
2
2
2
...

user output
2

Test 100

Group: 5

Verdict:

input
100000 99999
50234 26601 934
26601 98648 926
98648 57972 967
57972 43476 947
...

correct output
0
0
0
0
0
...

user output
0

Test 101

Group: 5

Verdict:

input
100000 99999
56054 80449 561
56054 9214 259
56054 62006 238
56054 80043 946
...

correct output
23
23
23
23
23
...

user output
23