QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#359395 | #410. Telegraph | Paz15 | 10 | 64ms | 3712kb | C++17 | 717b | 2024-03-20 17:28:45 | 2024-03-20 17:28:47 |
Judging History
answer
//fast
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
pair<int,int> tab[n+1];
for (int i = 1 ; i<=n ; i++){
cin >> tab[i].first >> tab[i].second;
}
int kier[n+1];
for (int i = 1 ; i<=n ; i++){
kier[i] = i;
}
ll w = 1e18+2137;
do{
ll pom = 0;
for (int i = 1 ; i<n ; i++){
if (tab[kier[i]].first!=kier[i+1]) pom+=tab[kier[i]].second;
}
if (tab[kier[n]].first!=kier[1]) pom+=tab[kier[n]].second;
w = min(w,pom);
}while (next_permutation(kier+1,kier+n+1));
cout << w << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 10
Accepted
Test #1:
score: 10
Accepted
time: 50ms
memory: 3624kb
input:
10 3 85377744 3 191391530 4 553475509 8 344887257 9 812158120 1 880268352 4 686078706 7 182546394 4 220137367 3 89957933
output:
1081551750
result:
ok single line: '1081551750'
Test #2:
score: 0
Accepted
time: 52ms
memory: 3612kb
input:
10 3 688989554 5 112566798 1 294281317 1 96941112 6 746415334 2 612836992 9 629868215 1 406822326 10 638640051 8 199983696
output:
503789227
result:
ok single line: '503789227'
Test #3:
score: 0
Accepted
time: 51ms
memory: 3568kb
input:
10 3 292601364 7 33742065 7 35087125 3 996478615 4 828156197 3 197921984 8 426174077 4 631098259 5 57142735 5 457493107
output:
1212506407
result:
ok single line: '1212506407'
Test #4:
score: 0
Accepted
time: 51ms
memory: 3628kb
input:
10 6 43696822 9 954917333 7 923376581 5 896016118 1 762413411 4 930490625 3 369963586 9 855374192 2 475645419 1 567518871
output:
1936096612
result:
ok single line: '1936096612'
Test #5:
score: 0
Accepted
time: 50ms
memory: 3564kb
input:
10 6 647308632 3 876092601 4 664182389 6 648069973 7 844154274 5 663059265 1 166269448 3 79650124 7 894148102 7 825028282
output:
2396141312
result:
ok single line: '2396141312'
Test #6:
score: 0
Accepted
time: 52ms
memory: 3500kb
input:
10 5 415342264 1 248144257 7 494844360 9 110058957 4 614196536 3 303926057 10 44559777 2 165167138 6 41487942 8 935054045
output:
0
result:
ok single line: '0'
Test #7:
score: 0
Accepted
time: 52ms
memory: 3628kb
input:
10 10 898367504 9 980712897 2 504348852 3 53848467 7 33871940 1 528201989 6 811131714 5 583669822 8 801282745 4 45079808
output:
0
result:
ok single line: '0'
Test #8:
score: 0
Accepted
time: 47ms
memory: 3568kb
input:
10 7 381392744 6 713281537 2 366369696 5 850154328 3 306063696 8 752477922 10 430220003 1 2172506 4 413593900 9 302589220
output:
0
result:
ok single line: '0'
Test #9:
score: 0
Accepted
time: 47ms
memory: 3568kb
input:
10 8 864417984 5 298366530 2 375874188 1 793943838 6 578255452 4 976753854 3 49308293 10 420675190 7 25905054 9 412614983
output:
0
result:
ok single line: '0'
Test #10:
score: 0
Accepted
time: 47ms
memory: 3556kb
input:
10 8 199959576 4 30935170 2 237895032 7 590249700 10 997930856 5 53546139 1 668396582 6 839177874 3 638216209 9 670124394
output:
0
result:
ok single line: '0'
Test #11:
score: 0
Accepted
time: 53ms
memory: 3656kb
input:
10 3 682984816 1 750527363 4 747399524 9 770122612 4 277822071 1 763503810 2 780150157 3 534039209 2 787484871 9 110196910
output:
2452735710
result:
ok single line: '2452735710'
Test #12:
score: 0
Accepted
time: 52ms
memory: 3572kb
input:
10 3 609420368 6 510322166 8 542314367 1 330345071 2 37659569 1 666010057 6 348588802 2 554056808 3 502098004 8 528699593
output:
1761005813
result:
ok single line: '1761005813'
Test #13:
score: 0
Accepted
time: 47ms
memory: 3632kb
input:
10 8 274134580 10 961989771 9 622633320 10 947202277 2 726373936 3 147685332 9 81157442 2 618924860 8 649035297 3 673145097
output:
2069104491
result:
ok single line: '2069104491'
Test #14:
score: 0
Accepted
time: 47ms
memory: 3572kb
input:
10 2 734181527 3 792233387 5 734944475 1 950649869 6 632060537 1 628429351 3 257711095 6 70440442 2 365704961 5 813726083
output:
2057230324
result:
ok single line: '2057230324'
Test #15:
score: 0
Accepted
time: 50ms
memory: 3684kb
input:
10 5 911321676 6 14229951 10 398811075 1 784207645 10 847255630 8 990450195 5 515220506 1 506373283 8 174925801 6 967602129
output:
1609560616
result:
ok single line: '1609560616'
Test #16:
score: 0
Accepted
time: 52ms
memory: 3576kb
input:
10 6 926048691 6 399201736 4 999954689 7 999954691 4 131379719 5 399201738 1 958019465 5 131379717 1 926048690 7 958019463
output:
2546029325
result:
ok single line: '2546029325'
Test #17:
score: 0
Accepted
time: 46ms
memory: 3568kb
input:
10 10 198240446 6 861975533 2 861975531 9 863948357 6 754325322 10 754325324 8 623477668 9 623477670 2 863948359 8 198240447
output:
2636259416
result:
ok single line: '2636259416'
Test #18:
score: 0
Accepted
time: 52ms
memory: 3624kb
input:
10 5 2 6 1 2 2 9 4 2 4 4 4 4 2 2 2 5 4 9 2
output:
11
result:
ok single line: '11'
Test #19:
score: 0
Accepted
time: 64ms
memory: 3676kb
input:
10 9 4 1 4 2 2 2 4 9 2 9 2 4 4 4 2 7 1 1 2
output:
11
result:
ok single line: '11'
Test #20:
score: 0
Accepted
time: 51ms
memory: 3676kb
input:
10 4 729237416 6 914170628 10 148821816 1 56295050 7 162299358 2 743005359 5 438210203 9 722952110 8 360316619 3 154246770
output:
1470738202
result:
ok single line: '1470738202'
Test #21:
score: 0
Accepted
time: 49ms
memory: 3712kb
input:
10 9 256452 7 373097749 6 470342382 8 605026203 10 234516065 3 358737448 2 773335059 4 499255620 1 668606205 5 434491114
output:
1465863334
result:
ok single line: '1465863334'
Test #22:
score: 0
Accepted
time: 52ms
memory: 3600kb
input:
10 7 854166518 5 231824260 10 701295161 3 280917360 6 178305574 9 597373681 4 392423348 2 727851793 8 418759136 1 614530695
output:
459222934
result:
ok single line: '459222934'
Test #23:
score: 0
Accepted
time: 47ms
memory: 3556kb
input:
10 8 476551539 5 837877557 10 122095084 6 40712162 3 964392900 1 36836753 4 11511637 7 126358274 2 837261820 9 821649614
output:
133606721
result:
ok single line: '133606721'
Test #24:
score: 0
Accepted
time: 50ms
memory: 3672kb
input:
10 6 2 8 2 4 2 3 1 9 1 7 1 8 1 5 2 6 2 4 2
output:
5
result:
ok single line: '5'
Test #25:
score: 0
Accepted
time: 51ms
memory: 3568kb
input:
10 6 2 9 2 2 2 6 2 6 1 7 1 3 1 1 1 2 2 9 1
output:
6
result:
ok single line: '6'
Test #26:
score: 0
Accepted
time: 52ms
memory: 3608kb
input:
10 8 2 3 2 1 2 8 1 2 2 8 1 1 2 4 1 7 2 6 2
output:
4
result:
ok single line: '4'
Test #27:
score: 0
Accepted
time: 50ms
memory: 3680kb
input:
10 9 1 4 2 7 2 1 1 1 1 9 3 6 1 7 1 3 3 2 2
output:
4
result:
ok single line: '4'
Test #28:
score: 0
Accepted
time: 52ms
memory: 3620kb
input:
10 9 2 6 3 5 2 2 3 6 1 8 2 4 3 3 1 8 2 8 2
output:
5
result:
ok single line: '5'
Test #29:
score: 0
Accepted
time: 51ms
memory: 3564kb
input:
10 9 3 6 3 2 2 5 2 3 3 1 2 9 3 5 3 6 1 7 1
output:
6
result:
ok single line: '6'
Test #30:
score: 0
Accepted
time: 50ms
memory: 3624kb
input:
10 2 4 8 3 8 5 5 4 8 4 2 3 8 4 9 3 3 4 3 3
output:
18
result:
ok single line: '18'
Test #31:
score: 0
Accepted
time: 50ms
memory: 3596kb
input:
10 3 2 1 5 6 3 7 4 7 2 3 3 5 3 4 1 8 3 9 2
output:
5
result:
ok single line: '5'
Test #32:
score: 0
Accepted
time: 47ms
memory: 3632kb
input:
10 3 2 3 3 5 1 9 2 4 1 2 3 1 3 7 4 4 4 5 3
output:
6
result:
ok single line: '6'
Test #33:
score: 0
Accepted
time: 52ms
memory: 3552kb
input:
10 7 2 3 1 10 2 1 2 9 2 3 2 6 2 4 2 8 2 5 2
output:
2
result:
ok single line: '2'
Test #34:
score: 0
Accepted
time: 51ms
memory: 3508kb
input:
10 4 2 6 2 9 1 2 2 10 2 7 2 5 2 9 2 1 2 8 2
output:
2
result:
ok single line: '2'
Test #35:
score: 0
Accepted
time: 52ms
memory: 3708kb
input:
10 4 3 6 3 2 3 8 1 9 3 5 3 1 3 3 3 7 3 4 1
output:
2
result:
ok single line: '2'
Test #36:
score: 0
Accepted
time: 51ms
memory: 3708kb
input:
10 9 3 1 3 5 3 7 3 10 3 2 3 6 1 7 1 3 3 4 3
output:
2
result:
ok single line: '2'
Test #37:
score: 0
Accepted
time: 51ms
memory: 3576kb
input:
10 3 724712539 3 253848450 6 356739170 3 814029021 3 121198630 3 482935623 3 674461095 3 302762682 3 263140130 3 908035622
output:
3637088170
result:
ok single line: '3637088170'
Test #38:
score: 0
Accepted
time: 55ms
memory: 3576kb
input:
10 8 373165894 8 38304954 8 946652851 8 68020615 8 672351134 8 520346777 8 246552191 4 839764410 8 740286919 8 586733383
output:
3245761867
result:
ok single line: '3245761867'
Test #39:
score: 0
Accepted
time: 51ms
memory: 3664kb
input:
10 2 322789650 7 800589256 5 218844607 10 132657931 8 115097238 4 90853818 1 596237875 3 42858053 4 630675305 6 359375208
output:
456501521
result:
ok single line: '456501521'
Test #40:
score: 0
Accepted
time: 51ms
memory: 3656kb
input:
10 8 509356502 1 125947146 7 339373171 3 638520011 8 740701068 9 805814890 4 986647562 2 892452734 10 533157896 6 458258719
output:
1306988392
result:
ok single line: '1306988392'
Test #41:
score: 0
Accepted
time: 1ms
memory: 3668kb
input:
4 2 73822429 1 696182050 1 415286834 3 921421058
output:
489109263
result:
ok single line: '489109263'
Test #42:
score: 0
Accepted
time: 0ms
memory: 3700kb
input:
6 3 258660948 4 317460220 5 307161079 3 306951059 2 624381722 3 329784054
output:
565612007
result:
ok single line: '565612007'
Test #43:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
6 3 443499466 1 86222039 4 199035324 3 692481060 1 107406962 3 339288546
output:
1068045375
result:
ok single line: '1068045375'
Test #44:
score: 0
Accepted
time: 0ms
memory: 3556kb
input:
7 6 628337985 3 707500209 2 90909568 5 78011060 4 590432202 4 201309390 6 874770682
output:
998568003
result:
ok single line: '998568003'
Test #45:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
7 4 813176504 5 328778380 4 130267461 5 611024709 1 73457443 1 210813882 4 146962438
output:
679465722
result:
ok single line: '679465722'
Test #46:
score: 0
Accepted
time: 0ms
memory: 3504kb
input:
2 2 998015023 1 939245867
output:
0
result:
ok single line: '0'
Test #47:
score: 0
Accepted
time: 51ms
memory: 3616kb
input:
10 9 218687433 6 82339218 7 150723185 10 838829597 4 909304699 8 607048818 5 143907993 3 326114464 2 953332355 1 396378244
output:
0
result:
ok single line: '0'
Test #48:
score: 0
Accepted
time: 53ms
memory: 3708kb
input:
10 6 951256073 8 91843710 1 94512695 9 111021353 2 133580631 5 226137107 3 562410677 4 938425619 10 63358118 7 32163581
output:
0
result:
ok single line: '0'
Subtask #2:
score: 0
Time Limit Exceeded
Dependency #1:
100%
Accepted
Test #49:
score: 0
Time Limit Exceeded
input:
15 12 85377744 1 191391530 11 553475509 9 344887257 3 812158120 7 880268352 8 686078706 11 182546394 13 220137367 6 89957933 10 715669848 3 196032869 5 68706224 12 212567593 13 964776170
output:
result:
Subtask #3:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%