QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#517753#8324. 迷宫守卫bribritt25 131ms4768kbC++17991b2024-08-13 13:41:022024-08-13 13:41:02

Judging History

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

  • [2024-08-13 13:41:02]
  • 评测
  • 测评结果:25
  • 用时:131ms
  • 内存:4768kb
  • [2024-08-13 13:41:02]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int n; ll k;
ll w[1<<16]; int c[1<<17];
int bt;
vector<int> comp(int x) {
  if(x&(1<<n)) return {c[x]};
  vector<int> l = comp(x<<1), r = comp(x<<1|1);
  vector<int> ans;
  if((bt&(1<<x))||(l<r)) {
    for(auto i: l) ans.push_back(i);
    for(auto i: r) ans.push_back(i);
  } else {
    for(auto i: r) ans.push_back(i);
    for(auto i: l) ans.push_back(i);
  }
  return ans;
}
void solve() {
  cin >> n >> k;
  for(int i=1;i<(1<<n);i++) cin>>w[i];
  for(int i=0;i<(1<<n);i++) cin>>c[(1<<n)|i];
  vector<int> ans = {0};
  for(bt=0;bt<(1<<(1<<n));bt++) {
    ll cnt = 0;
    for(int i=1;i<(1<<n);i++) if(bt&(1<<i)) cnt+=w[i];
    if(cnt>k) continue;
    ans=max(ans,comp(1));
  }
  for(auto i: ans) cout<<i<<" "; cout<<"\n";
}
main() {
  int t; cin >> t;
  while(t--) solve();
}
/*

              3
      2               1
  2       1       2       1
4   2   6   3   7   1   5   8
*/

详细


Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 130ms
memory: 3520kb

input:

5
4 41704513771
63172871346 30595220734 16095671102 3822055819 13738718698 5991071599 14075850903 6874431191 1954448141 4475339255 4509212246 3504301339 4327559573 3485545593 2074035498
7 9 5 16 3 4 1 11 14 12 2 8 15 6 13 10
4 63715445249
61413836337 11125139971 8494516376 13086757419 19161322522 93...

output:

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

result:

ok 5 lines

Test #2:

score: 5
Accepted
time: 58ms
memory: 3516kb

input:

5
4 77339380239
81895899866 48344406140 3046718575 7110699715 3972565764 7732374665 6292498163 12486498794 3363604 9980601599 6263469257 3057425890 2429533238 4572510501 2187576167
15 2 5 7 1 13 14 10 3 4 16 8 9 11 6 12
4 37630135888
44732450063 40210162157 6384089682 4618779030 8328589818 147568590...

output:

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

result:

ok 5 lines

Test #3:

score: 5
Accepted
time: 103ms
memory: 3520kb

input:

5
4 34893391512
26053943776 45137145772 9525790347 6244540920 15146115409 8558045030 2197707629 2912706108 8598620741 9616527941 5107315902 7164914802 3758081752 1728413392 3704449708
1 5 3 2 16 15 11 9 7 10 12 13 6 14 8 4
4 31567183393
10985614313 25547317620 20499357354 3806371768 864415909 420391...

output:

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

result:

ok 5 lines

Test #4:

score: 5
Accepted
time: 131ms
memory: 3584kb

input:

5
4 64526803118
81700304744 29570105266 13540707295 5272323562 7638728067 8087907239 2844705697 12147211174 5137101764 358865602 4913699397 2913573812 3870170710 2834045717 2569759294
3 6 4 13 1 8 11 12 9 16 2 5 7 14 15 10
4 48301519274
22007257328 28325952217 10828692751 6900017612 3320794226 42011...

output:

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

result:

ok 5 lines

Test #5:

score: 5
Accepted
time: 60ms
memory: 3596kb

input:

5
4 4863158478
40607600527 2421619125 32450416748 10777143852 5594001099 11510465755 2056752878 7334350461 5373375310 7205056137 494938545 3987861103 3739397274 7072693146 4300805097
8 12 14 9 1 11 7 2 13 5 15 10 6 16 3 4
4 50212387584
1103380725 64230244 17714471343 22345342654 11697933803 95423187...

output:

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

result:

ok 5 lines

Test #6:

score: 0
Wrong Answer
time: 0ms
memory: 3776kb

input:

5
6 54745168585
23433156564 23536806253 15372713850 18216219454 8589226497 10865021681 2253546280 907002273 5317503603 475806625 82106518 690500370 6959464451 6238313289 2696179814 2324765017 2290127697 3363593390 342590783 121348581 771888970 4362965169 3207675963 2439991837 587957532 1343945881 18...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 
1 2 3 4 5 6 7 8 9 10 11 12 1...

result:

wrong answer 1st lines differ - expected: '53 54 56 55 51 52 49 50 58 57 ...2 23 24 25 26 27 28 29 30 31 32', found: '1 2 3 4 5 6 7 8 9 10 11 12 13 ... 55 56 57 58 59 60 61 62 63 64 '

Test #7:

score: 0
Wrong Answer
time: 0ms
memory: 3776kb

input:

5
6 12
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
26 38 60 53 48 54 5 32 19 27 20 7 4 61 44 30 62 63 37 43 9 58 33 13 24 18 50 6 34 3 2 57 41 29 28 55 52 17 8 1 22 10 46 40 16 36 15 21 23 45 49 64 42 35 39 11 47 31 12...

output:

1 8 17 52 28 55 29 41 10 22 40 46 15 21 16 36 11 39 35 42 23 45 49 64 12 14 31 47 25 56 51 59 2 57 3 34 6 50 18 24 9 58 13 33 37 43 62 63 4 61 30 44 7 20 19 27 5 32 48 54 26 38 53 60 
1 31 7 14 2 3 5 8 6 24 20 23 9 28 13 27 4 25 10 15 12 30 19 29 11 16 18 26 17 32 21 22 
1 13 8 29 6 24 9 10 5 20 22 ...

result:

wrong answer 1st lines differ - expected: '26 38 60 53 48 54 5 32 19 27 2...5 49 64 12 14 31 47 25 56 51 59', found: '1 8 17 52 28 55 29 41 10 22 40...0 19 27 5 32 48 54 26 38 53 60 '

Test #8:

score: 0
Wrong Answer
time: 1ms
memory: 3584kb

input:

5
6 15
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
35 4 24 16 55 20 49 5 17 32 25 14 23 19 57 18 31 1 45 8 3 58 2 59 60 51 40 13 9 21 61 29 46 41 30 44 42 56 48 7 27 28 22 54 52 34 47 26 43 10 33 11 63 62 37 50 38 39 6...

output:

1 31 8 45 2 59 3 58 9 21 29 61 13 40 51 60 4 35 16 24 5 49 20 55 14 25 17 32 18 57 19 23 6 53 38 39 12 64 15 36 10 43 11 33 37 50 62 63 7 48 42 56 30 44 41 46 22 54 27 28 26 47 34 52 
1 18 8 20 11 25 26 32 5 17 28 31 9 16 13 24 2 22 3 12 6 23 7 19 4 27 15 30 10 14 21 29 
1 27 13 21 7 11 10 15 17 20 ...

result:

wrong answer 1st lines differ - expected: '35 4 24 16 55 20 49 5 17 32 25...4 41 46 22 54 27 28 26 47 34 52', found: '1 31 8 45 2 59 3 58 9 21 29 61... 41 46 22 54 27 28 26 47 34 52 '

Test #9:

score: 0
Wrong Answer
time: 0ms
memory: 3584kb

input:

5
6 41682514268
65512460533 23389539380 17127541806 13879623608 18454598020 11859665553 4427727406 9224733854 10393341296 8919804232 8517294999 7182700425 6740147596 4027193471 2058512521 792633359 4533477482 980684284 2664612081 4521381730 2856886140 1715375705 1335499956 1378534167 1242250449 3240...

output:

1 20 46 57 2 36 32 45 3 53 7 23 13 54 40 49 5 52 21 38 18 41 30 34 14 26 15 48 17 33 37 51 4 62 25 55 11 42 58 60 8 50 39 56 10 12 44 61 6 9 47 64 22 24 27 43 16 29 35 63 19 28 31 59 
1 9 4 23 6 30 10 24 8 18 26 31 13 25 14 27 2 22 17 19 3 20 28 32 5 15 21 29 7 16 11 12 
1 30 4 21 12 14 19 26 2 27 2...

result:

wrong answer 1st lines differ - expected: '15 48 14 26 33 17 37 51 21 38 ...12 44 61 42 11 58 60 4 62 25 55', found: '1 20 46 57 2 36 32 45 3 53 7 2... 27 43 16 29 35 63 19 28 31 59 '

Test #10:

score: 0
Wrong Answer
time: 0ms
memory: 3820kb

input:

5
6 24811678845
59366612184 49154633743 6012028601 18488464455 3698079115 15237755546 9897513757 11297313825 1235390268 9537679832 6527345169 6788541803 6092835632 3757166512 2775821228 5038810767 5132680421 224613865 3922090240 3516928234 4550183827 807384027 3474382046 2163118984 1933277169 237629...

output:

1 59 10 45 13 34 36 54 5 17 23 56 27 53 43 50 2 57 9 49 3 22 7 52 6 58 25 40 16 26 24 29 4 47 8 46 14 48 61 64 12 44 39 60 18 31 51 55 11 20 30 38 19 41 32 42 15 28 33 37 21 62 35 63 
1 28 5 7 18 26 19 24 2 3 12 14 4 17 13 31 6 10 8 30 11 15 25 27 9 22 20 23 16 21 29 32 
1 28 7 22 15 29 16 26 2 17 1...

result:

wrong answer 1st lines differ - expected: '3 22 7 52 9 49 2 57 16 26 29 2...5 37 33 32 42 41 19 38 30 20 11', found: '1 59 10 45 13 34 36 54 5 17 23... 32 42 15 28 33 37 21 62 35 63 '

Test #11:

score: 0
Wrong Answer
time: 2ms
memory: 3872kb

input:

8
11 8529168063
96069180507 14546522039 16201831539 11081688135 14127492888 5483527826 5423117536 5383419437 4400835611 4101982754 1519595961 5245792592 361617983 2749618781 1961362420 6071049745 3218074367 883237862 766782110 1284574799 1163029746 1829051469 1302409327 2105572087 1587995436 2901202...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

wrong answer 1st lines differ - expected: '394 393 396 395 397 398 400 39...2 2043 2044 2045 2046 2047 2048', found: '1 2 3 4 5 6 7 8 9 10 11 12 13 ... 2043 2044 2045 2046 2047 2048 '

Test #12:

score: 0
Wrong Answer
time: 1ms
memory: 3872kb

input:

8
11 571
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1 56 92 150 2 10 163 405 6 45 59 179 27 48 50 54 7 67 25 86 18 481 49 187 19 58 114 199 23 66 24 29 11 140 43 94 44 134 104 162 30 171 112 465 32 387 51 172 13 81 37 55 31 34 273 532 17 46 35 63 47 460 96 108 3 115 12 82 21 100 42 139 4 16 36 89 122 149 124 234 5 90 87 110 33 169 182 265 41 85 52 32...

result:

wrong answer 1st lines differ - expected: '1960 1995 2047 1968 1956 2044 ...433 472 464 578 440 488 446 768', found: '1 56 92 150 2 10 163 405 6 45 ... 2000 2004 1960 1995 1968 2047 '

Test #13:

score: 0
Wrong Answer
time: 1ms
memory: 3528kb

input:

8
11 252
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1 49 100 616 32 71 52 85 7 178 37 101 62 86 126 182 9 70 40 115 17 35 78 144 11 96 42 106 114 143 139 226 2 10 21 215 4 34 44 82 24 77 63 248 33 104 75 121 5 118 83 99 27 103 184 310 6 16 68 295 15 555 243 382 3 74 76 154 46 92 95 259 8 12 30 127 36 80 219 280 13 31 25 180 20 246 65 145 14 108 38 57...

result:

wrong answer 1st lines differ - expected: '1961 1998 2002 1969 2013 2044 ...8 1030 1127 1016 1152 1027 1044', found: '1 49 100 616 32 71 52 85 7 178... 1969 2002 1967 2025 2013 2044 '

Test #14:

score: 0
Wrong Answer
time: 2ms
memory: 3876kb

input:

8
11 170392530264
74651887849 17611792511 11288590546 6568520318 11787580396 1038293275 8132485406 811722341 6463339368 5578666288 6988124667 5250658163 7545924747 436981583 4449296950 4837617209 5423956155 3263388134 1290388306 4273188134 2502801698 455787408 2184397509 900391791 934924549 11250348...

output:

1 148 25 244 6 17 42 43 11 322 28 89 41 104 109 114 10 31 120 151 14 92 54 215 24 58 76 124 27 247 72 270 20 63 118 122 30 226 37 121 38 78 40 70 45 135 88 123 26 376 66 156 49 140 142 182 44 323 107 341 74 231 133 136 2 21 36 337 5 174 15 35 12 96 23 187 18 159 19 83 13 128 52 192 57 62 64 65 22 19...

result:

wrong answer 1st lines differ - expected: '1963 2048 2036 2029 2006 2044 ... 1220 944 1014 927 984 954 1030', found: '1 148 25 244 6 17 42 43 11 322... 2029 2036 1987 2043 2006 2044 '

Test #15:

score: 0
Wrong Answer
time: 0ms
memory: 3576kb

input:

8
11 10817060597
85858621967 47769507919 2550569053 4936407038 4200947363 15181090532 2195335264 1279109336 9430376850 3667617132 2581310809 1530224542 7058648206 133323350 150591857 3490174463 5246064700 5403826000 616788461 4805350827 2971535312 1549457606 1430948590 1859856676 2761221467 10782807...

output:

1 217 45 116 12 83 19 134 3 46 154 205 9 16 136 153 13 68 22 566 23 50 55 307 32 42 102 113 90 98 238 414 15 48 43 324 30 52 33 54 18 80 40 349 35 72 106 212 25 144 74 203 31 140 62 119 47 97 63 130 57 196 61 129 2 8 41 65 20 75 210 334 24 29 202 385 64 94 149 293 5 105 28 148 14 38 82 88 11 71 37 9...

result:

wrong answer 1st lines differ - expected: '679 772 801 723 707 751 891 94...2 1999 2045 1954 2048 1993 2001', found: '1 217 45 116 12 83 19 134 3 46... 1999 2045 1954 2048 1993 2001 '

Test #16:

score: 0
Wrong Answer
time: 49ms
memory: 4596kb

input:

17
16 185467288814
92060578373 47290795643 9286036925 9228394756 4811881952 8646592030 8944909812 2841304722 6070010500 6008789791 6082937518 4490550145 5615562853 6824949729 4377456320 5710382139 2189154879 2907374836 4635243843 815487121 3594634884 1123206624 3451101389 1464409182 3816376047 99149...

output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 ...

result:

wrong answer 1st lines differ - expected: '65536 65535 65534 65533 65532 ...3 32764 32765 32766 32767 32768', found: '1 2 3 4 5 6 7 8 9 10 11 12 13 ... 65532 65533 65534 65535 65536 '

Test #17:

score: 0
Wrong Answer
time: 37ms
memory: 4768kb

input:

17
16 8329
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

1 10 24 226 18 36 55 151 3 73 14 19 4 324 72 81 11 88 90 198 48 154 67 231 23 82 32 162 25 83 75 475 5 79 80 147 7 182 38 349 9 77 89 113 39 135 87 123 16 141 47 127 34 150 94 99 52 111 130 300 59 166 153 467 2 37 109 204 13 22 71 91 8 102 68 601 15 185 163 169 12 84 60 344 41 298 45 78 17 98 28 43 ...

result:

wrong answer 1st lines differ - expected: '65444 65489 65480 65475 65464 ...4 32839 32740 32784 32816 33001', found: '1 10 24 226 18 36 55 151 3 73 ... 65486 65478 65527 65528 65529 '

Test #18:

score: 0
Wrong Answer
time: 38ms
memory: 4680kb

input:

17
16 15956
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1 38 56 87 20 129 89 206 48 93 77 80 54 237 131 179 6 13 46 52 14 155 26 34 8 39 172 180 94 188 107 154 4 250 51 194 16 543 31 108 28 40 136 222 45 210 103 230 22 27 71 73 32 43 109 123 60 100 139 140 72 110 88 147 2 101 35 125 30 95 165 401 25 308 37 59 81 198 117 223 5 65 24 49 7 23 17 134 11 36 1...

result:

wrong answer 1st lines differ - expected: '65448 65536 65535 65467 65533 ...8 32873 32681 32838 32686 32719', found: '1 38 56 87 20 129 89 206 48 93... 65533 65448 65536 65467 65535 '

Test #19:

score: 0
Wrong Answer
time: 46ms
memory: 4680kb

input:

17
16 123563911790
35459655441 43632569067 27856417624 17183249762 11408415432 6410374431 4355108219 10839722895 1557427267 8039957610 3261023448 863292515 2321876702 4529787424 6094181663 5552293666 1229609052 3243632422 3258596121 2777539196 218149318 857735919 4190629450 13122153 235727176 405797...

output:

1 76 12 149 13 133 19 166 6 23 72 275 7 8 63 243 17 231 77 293 28 245 139 308 29 35 70 205 79 130 128 451 20 39 25 285 24 344 37 40 27 80 140 156 51 263 108 132 30 142 84 215 32 61 125 171 34 50 83 250 208 303 252 284 2 15 42 223 9 94 44 138 3 38 26 111 33 113 65 69 4 16 59 95 10 193 58 62 5 386 46 ...

result:

wrong answer 1st lines differ - expected: '65449 65483 65462 65496 65533 ...2 32750 32702 32856 32739 32741', found: '1 76 12 149 13 133 19 166 6 23... 65496 65471 65480 65502 65533 '

Test #20:

score: 0
Wrong Answer
time: 46ms
memory: 4680kb

input:

17
16 2433509850
94402852594 4739314371 10807842811 23113510462 3844106361 15285318548 11429331314 4513086672 6976145076 7406862331 3902969782 4483098352 4142852842 6501115945 6642627273 3048275771 3986632722 890509821 3063792232 3653510136 2720826892 1129556719 655572505 3248045315 2596327240 19596...

output:

1 191 116 129 64 697 101 240 41 47 53 69 65 90 66 131 7 192 103 172 9 68 25 251 40 63 80 364 155 346 219 277 3 39 22 154 6 19 85 509 5 38 29 79 8 21 11 46 10 55 13 98 142 339 166 253 28 228 48 54 61 163 94 175 2 344 147 225 17 37 59 159 15 234 72 118 42 87 45 247 20 115 30 89 136 293 235 336 34 84 5...

result:

wrong answer 1st lines differ - expected: '3163 3042 2994 3028 3056 3044 ...4 65521 65502 65528 65526 65527', found: '1 191 116 129 64 697 101 240 4... 65521 65502 65528 65526 65527 '