QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#39942#4357. School RoadZeinDaner7 116ms10848kbC++688b2022-07-15 04:27:212022-07-15 04:27:24

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-07-15 04:27:24]
  • 评测
  • 测评结果:7
  • 用时:116ms
  • 内存:10848kb
  • [2022-07-15 04:27:21]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll> il;
typedef vector<il> vil;
vector<vil> G;
bool vis[50];
ll tw=0;
int n,m;
ll mi=1e18,ma=0;
void back(int u){
  if(u==n-1){
    mi=min(mi,tw);
    ma=max(ma,tw);
    return;
  }
  for(auto &v:G[u]){
    if(!vis[v.first]){
      vis[v.first]=1;
      tw+=v.second;
      back(v.first);
      tw-=v.second;
      vis[v.first]=0;
    }
  }
}
int main(){
   cin>>n>>m;
   G.resize(n+1);
  for(int i=0;i<m;i++){
    int a,b,w; cin>>a>>b>>w;
    a--; b--;
    G[a].push_back(il(b,w));
    G[b].push_back(il(a,w));
  }
  vis[0]=1;
  back(0);
  cout<<(mi<ma)<<endl;
}

詳細信息

Subtask #1:

score: 7
Accepted

Test #1:

score: 7
Accepted
time: 0ms
memory: 3436kb

input:

14 40
8 12 570429827
6 10 592780730
13 14 299807355
4 10 729771483
4 10 729771483
6 9 746405411
2 3 696576351
12 14 192640790
4 13 284900209
1 2 857968292
12 14 192640790
8 12 570429827
6 10 592780730
6 9 746405411
9 11 329648726
4 13 284900209
2 3 696576351
4 10 729771483
5 11 101819611
3 7 1824073...

output:

0

result:

ok single line: '0'

Test #2:

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

input:

41 40
12 19 102666211
30 32 10931929
8 34 88862177
11 29 37284876
6 35 24117284
6 11 24483138
10 35 11019124
4 22 509961847
20 39 77098829
25 33 563195350
22 24 781289886
2 17 238185039
21 27 288940653
3 31 62767763
18 21 350694322
2 40 228181439
3 33 109276182
31 36 203571934
28 34 64098677
14 24 3...

output:

0

result:

ok single line: '0'

Test #3:

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

input:

41 40
2 21 69489336
7 32 715357509
25 38 324791430
1 39 430674626
15 40 551039547
5 18 334574228
23 37 712919654
9 27 367576234
15 38 171641096
5 36 183325856
1 6 339460052
23 26 796129406
31 35 572322695
34 35 783409641
2 4 754027046
8 33 413068373
29 33 900915508
10 13 296104622
32 39 88880510
17 ...

output:

0

result:

ok single line: '0'

Test #4:

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

input:

40 40
7 39 44916253
4 18 958910119
9 37 670785398
3 8 753908936
34 39 917194277
25 31 554847014
6 36 606005704
3 20 104555289
29 31 898892301
4 10 641381082
24 30 321262615
15 24 978365334
13 19 237154728
1 30 159127129
1 38 273921427
33 35 95259264
35 40 9238012
9 25 518899851
12 22 920531620
32 38...

output:

1

result:

ok single line: '1'

Test #5:

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

input:

30 40
19 21 328185293
13 14 22819556
2 27 273153157
14 26 50384094
11 25 494531515
25 30 359616654
11 16 375002721
18 23 164262510
5 10 407165307
11 12 711507970
1 2 848916038
7 20 859256691
8 29 134750932
26 28 47526931
3 11 113645452
9 30 342513122
17 28 80149357
13 14 22819556
3 22 124561707
11 2...

output:

1

result:

ok single line: '1'

Test #6:

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

input:

33 40
20 26 79109023
6 29 87482145
19 28 108079769
17 18 102220134
22 28 292589957
24 27 26800309
3 11 205934054
27 32 114321362
11 31 211432408
9 15 110500168
12 30 258718383
3 31 417366462
14 20 77042954
7 33 118897642
16 25 181993587
4 23 61594382
9 13 31839463
1 6 70777151
23 29 84725031
1 8 102...

output:

0

result:

ok single line: '0'

Test #7:

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

input:

41 40
8 39 632221620
7 20 764538283
14 24 639155356
28 30 568077302
13 37 522364121
4 38 92774017
1 23 37304415
2 32 863270576
9 31 747710956
24 28 827622223
25 35 157923723
23 27 782934506
20 33 753445053
29 30 194578597
11 26 191035416
7 15 59579013
3 29 184966209
15 41 203044654
11 12 164518265
1...

output:

0

result:

ok single line: '0'

Test #8:

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

input:

41 40
6 40 772449101
33 38 422577889
29 34 564405479
29 35 23989264
28 41 473451881
16 35 381757868
27 32 935802567
6 38 578727900
1 25 403637435
13 18 627709235
9 28 532310592
12 24 419349763
12 15 210295361
15 27 985536752
33 34 554957965
3 14 384539999
8 11 80181363
22 30 948552140
21 23 77411515...

output:

0

result:

ok single line: '0'

Test #9:

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

input:

41 40
9 14 360071850
14 16 781292052
14 36 602774678
14 21 320211599
14 26 860713037
14 23 760037999
14 18 426129216
14 39 137282699
11 14 939319423
14 31 150261087
1 14 192913833
7 14 238014224
14 41 104788269
8 14 443715883
14 22 449061542
14 20 350902310
14 24 919620275
12 14 816025354
13 14 3325...

output:

0

result:

ok single line: '0'

Test #10:

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

input:

28 40
16 24 629218825
17 25 565620030
14 22 533467091
15 21 352185235
10 19 400657459
4 19 479174146
5 25 612009652
1 8 102517927
13 20 474376845
18 24 168044848
9 22 295542298
21 28 42220224
15 21 352185235
16 24 629218825
14 27 834477227
23 26 191617965
2 7 763624125
3 26 498390954
12 18 3891669
1...

output:

0

result:

ok single line: '0'

Subtask #2:

score: 0
Time Limit Exceeded

Test #11:

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

input:

18 40
3 10 26965732
5 15 67047331
3 17 42474964
13 15 129212204
9 18 142540287
2 14 27157962
5 15 67047331
5 15 67047331
5 15 67047331
4 16 212978971
6 12 51548223
4 18 192438222
13 16 60052417
16 17 162364835
6 17 55527270
9 11 58810843
3 7 95393586
13 15 129212204
2 17 67824762
5 15 67047331
15 16...

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3532kb

input:

18 51
5 16 489370441
7 8 674383722
8 11 602435525
1 10 856666364
13 18 650829027
11 14 198398173
3 4 613940394
15 17 123758204
8 11 602435525
3 6 567757815
13 18 650829027
14 15 236674174
3 4 613940394
5 18 956980171
6 16 887883755
3 6 567757815
6 16 887883755
5 18 956980171
4 10 339471731
11 14 198...

output:

0

result:

ok single line: '0'

Test #13:

score: -15
Time Limit Exceeded

input:

18 200000
8 17 279042056
12 13 907447344
2 16 240997679
3 7 820773384
1 5 45712022
2 16 240997679
4 18 239293113
9 14 389857788
4 18 239293113
4 18 239293113
1 11 409366186
3 12 208134361
2 16 240997679
13 17 263089947
1 5 45712022
4 18 239293113
4 7 528521172
2 9 629050323
8 17 279042056
12 13 9074...

output:


result:


Subtask #3:

score: 0
Runtime Error

Test #18:

score: 0
Runtime Error

input:

100000 99999
42115 93495 19881095
21969 68351 161710
7405 86343 27129
37307 45676 320013
30388 71545 117761
22026 68957 65332
77949 81644 2281387
24865 95079 341488
9849 98496 2548159
53911 79572 4962105
24880 62622 1678564
15943 22168 1524688
67424 78323 2450655
32175 74893 1908332
35640 39305 1043...

output:


result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #57:

score: 35
Accepted
time: 3ms
memory: 3572kb

input:

18 400
11 18 145314505
1 18 242896789
1 18 242896789
5 13 31030812
13 18 93451080
1 18 242896789
1 7 123378068
1 18 242896789
1 18 242896789
1 18 242896789
1 18 242896789
1 18 242896789
1 18 242896789
1 3 42183985
1 18 242896789
13 18 93451080
1 18 242896789
13 18 93451080
1 18 242896789
1 18 242896...

output:

0

result:

ok single line: '0'

Test #58:

score: 0
Accepted
time: 116ms
memory: 10848kb

input:

18 200000
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 758096510
1 18 ...

output:

0

result:

ok single line: '0'

Test #59:

score: -35
Time Limit Exceeded

input:

18 200000
1 16 142470606
1 16 142470606
1 16 142470606
1 16 142470606
1 18 403405575
1 18 403405575
1 18 403405575
1 18 403405575
1 18 403405575
1 16 142470606
1 16 142470606
1 18 403405575
1 18 403405575
1 18 403405575
1 18 403405575
1 18 403405575
1 16 142470606
1 18 403405575
1 16 142470606
16 18...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%