QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#119624#6669. Mapahos_lyric#0 3ms4092kbC++145.2kb2023-07-05 12:53:542024-07-04 00:18:14

Judging History

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

  • [2024-07-04 00:18:14]
  • 评测
  • 测评结果:0
  • 用时:3ms
  • 内存:4092kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-05 12:53:54]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


int mix(int x) {
  x = (20230705LL * x) % 1'000'000'403;
  return x;
}

constexpr int E = 30;
constexpr int F = 11;
constexpr int GP = 5;
constexpr int GM = 7;
constexpr int M0 = 150;

string toBinary(int len, int x) {
  string s(len, '?');
  for (int e = 0; e < len; ++e) s[e] = "01"[x >> e & 1];
  return s;
}
int fromBinary(const string &s) {
  const int len = s.size();
  int x = 0;
  for (int e = 0; e < len; ++e) x |= (s[e] - '0') << e;
  return x;
}

string encode(int N, const vector<int> &X, const vector<int> &Y) {
  string S;
  
  int P;
  vector<int> H(N);
  for (int a = 0; a < 1 << GP; ++a) {
    P = (1 << F) - 1 - a;
    for (int i = 0; i < N; ++i) {
      H[i] = mix(X[i]) % P;
    }
    if ((int)set<int>(H.begin(), H.end()).size() == N) {
cerr<<"perfect a = "<<a<<", P = "<<P<<endl;
      S += toBinary(GP, a);
      goto foundPerfect;
    }
  }
  assert(false);
 foundPerfect:{}
  
  int minCost = 1001001001;
  int am = -1;
  for (int a = 0; a < 1 << GM; ++a) {
    const int M = M0 + a;
    vector<int> freq(M);
    for (int i = 0; i < N; ++i) {
      ++freq[H[i] % M];
    }
    int cost = M;
    for (int m = 0; m < M; ++m) {
      cost += F * max(freq[m] - 1, 0);
    }
cerr<<"M = "<<M<<": cost = "<<cost<<endl;
    if (chmin(minCost, cost)) {
      am = a;
    }
  }
  const int M = M0 + am;
  S += toBinary(GM, am);
  
  vector<vector<pair<int, int>>> hiss(M);
  for (int i = 0; i < N; ++i) {
    hiss[H[i] % M].emplace_back(H[i], i);
  }
  for (int m = 0; m < M; ++m) {
    auto &his = hiss[m];
    sort(his.begin(), his.end());
  }
// cerr<<"hiss = "<<hiss<<endl;
  for (int m = 0; m < M; ++m) {
    const auto &his = hiss[m];
    for (const auto &hi : his) {
      const int i = hi.second;
      S += toBinary(E, Y[i]);
    }
  }
  for (int m = 0; m < M; ++m) {
    const auto &his = hiss[m];
    S += (!his.empty()) ? '1' : '0';
  }
  for (int m = 0; m < M; ++m) {
    const auto &his = hiss[m];
    for (int j = 1; j < (int)his.size(); ++j) {
      S += toBinary(F, his[j].first);
    }
  }
  return S;
}

vector<int> decode(int N, int Q, int K, const string &S, const vector<int> &Z) {
  int P, M;
  map<int, int> mapa, nazo;
  {
    int cur = 0;
    P = (1 << F) - 1 - fromBinary(S.substr(cur, GP)); cur += GP;
    const int am = fromBinary(S.substr(cur, GM)); cur += GM;
    M = M0 + am;
    vector<int> Y(N);
    for (int i = 0; i < N; ++i) {
      Y[i] = fromBinary(S.substr(cur, E)); cur += E;
    }
    vector<vector<int>> hss(M);
    for (int m = 0; m < M; ++m) {
      const char any = S[cur++];
      if (any != '0') {
        hss[m].push_back(-1);
      }
    }
    for (; cur < K; ) {
      const int h = fromBinary(S.substr(cur, F)); cur += F;
      hss[h % M].push_back(h);
    }
// cerr<<"hss = "<<hss<<endl;
    {
      int i = 0;
      for (int m = 0; m < M; ++m) {
        for (const int h : hss[m]) {
          const int y = Y[i++];
          if (~h) {
            mapa[h] = y;
          } else {
            nazo[m] = y;
          }
        }
      }
    }
    assert(cur == K);
  }
  vector<int> ans(Q);
  for (int q = 0; q < Q; ++q) {
    const int h = mix(Z[q]) % P;
    auto it = mapa.find(h);
    if (it != mapa.end()) {
      ans[q] = it->second;
    } else {
      ans[q] = nazo[h % M];
    }
  }
  return ans;
}

int main() {
  int T;
  scanf("%d", &T);
  if (T == 1) {
    int N;
    scanf("%d", &N);
    vector<int> X(N), Y(N);
    for (int i = 0; i < N; ++i) {
      scanf("%d%d", &X[i], &Y[i]);
    }
    const string S = encode(N, X, Y);
    const int K = S.size();
    printf("%d\n", K);
    puts(S.c_str());
  } else {
    int N, Q, K;
    scanf("%d%d%d", &N, &Q, &K);
    char buf[6010];
    scanf("%s", buf);
    const string S = buf;
    vector<int> Z(Q);
    for (int q = 0; q < Q; ++q) {
      scanf("%d", &Z[q]);
    }
    const auto ans = decode(N, Q, K, S, Z);
    for (int q = 0; q < Q; ++q) {
      printf("%d\n", ans[q]);
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 89.3667
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 3788kb,4052kb

input:

1
100
495528311 963488152
269613430 443544124
700489871 792354118
151890319 506569919
180452297 13229948
684464994 543841485
978085128 903812192
238355172 441140842
28061035 783291471
530823766 718942732
936853023 439421263
201361623 226633955
304644844 778868118
864860135 461524170
88300500 6959354...

output:

3319
1100100001011111001010010000100011000101100011110110001011001011111111010110001010111010010111001111010001011001111011100111110011010100100000011011001101011101000011010100110001001011101001110001111010000111011111100100100101111110110000000010010100111011010001111100101110100100000101011001100...

input:

2
100 79 3319
1100100001011111001010010000100011000101100011110110001011001011111111010110001010111010010111001111010001011001111011100111110011010100100000011011001101011101000011010100110001001011101001110001111010000111011111100100100101111110110000000010010100111011010001111100101110100100000101...

output:

310305144
821194635
174780370
903812192
805026231
996046536
439421263
645287342
90686849
20101025
440972097
543841485
176553522
249563964
461524170
348624865
848301562
506569919
306718453
206848250
382805509
278712030
964702808
868944393
493895143
39665197
574757075
441140842
785665865
229376884
551...

result:

points 0.89366666670 ok K = 3319

Test #2:

score: 88.8
Acceptable Answer
time: 1ms = 1ms + 0ms
memory: 3820kb,3804kb

input:

1
100
743248071 842720888
367650901 130970775
297946283 705168964
771526942 537186020
245003150 707948455
643491261 668001146
311535032 293708068
183828318 18515526
593973840 915870006
102456762 64193833
729806890 839221652
47145974 35682954
668676377 228428310
370700393 569441954
250911162 48980047...

output:

3336
1111001101010001110000100111101010110100001111011000110110101111000001100010001100000100001111000001001001010010100001110010111100000111111000000011001010111110001110001001010100000011110000110110010001001011010100100000110001011110011011000011101001010001111001101000010000010111100010110100010...

input:

2
100 79 3336
1111001101010001110000100111101010110100001111011000110110101111000001100010001100000100001111000001001001010010100001110010111100000111111000000011001010111110001110001001010100000011110000110110010001001011010100100000110001011110011011000011101001010001111001101000010000010111100010...

output:

442563406
97578442
469403815
293708068
138158276
720700065
839221652
674386240
810209830
563527225
259979005
668001146
813899310
943777483
569441954
226088806
825435650
537186020
131383422
83733737
830289758
425793016
858146541
609883097
414389335
407054915
47572024
18515526
276587480
810627636
4972...

result:

points 0.8880 ok K = 3336

Test #3:

score: 88.9333
Acceptable Answer
time: 1ms = 1ms + 0ms
memory: 3988kb,4040kb

input:

1
100
770174568 168127255
893508708 185778664
976425263 477317099
287595878 512153851
621600374 418802856
818787535 612197605
796811122 566496677
789841517 873731343
43178468 619503942
597852289 471053284
66112404 635260765
158101403 199253397
680158192 123081916
626776438 29107026
721141470 5177084...

output:

3332
0001010100001100100010001110111010010110110001001001011111011001110001011000001101000001000000101011011111101011001111010010101100111110001100110011100110010100111010000101001000000011100110000011110010001101110000101011000101110011000011100111000001110000000101111000101111100111100110000011111...

input:

2
100 79 3332
0001010100001100100010001110111010010110110001001001011111011001110001011000001101000001000000101011011111101011001111010010101100111110001100110011100110010100111010000101001000000011100110000011110010001101110000101011000101110011000011100111000001110000000101111000101111100111100110...

output:

676203467
418593456
222540092
566496677
487711174
155177230
635260765
19655934
405420089
197948311
16997620
612197605
623431791
654167214
29107026
103769907
951695033
512153851
401411177
839097490
141196222
886472586
767476542
270436089
885084406
492744649
861074271
873731343
744691837
300804222
364...

result:

points 0.88933333330 ok K = 3332

Test #4:

score: 89.1
Acceptable Answer
time: 0ms = 0ms + 0ms
memory: 3824kb,3748kb

input:

1
100
546594289 9670068
665528790 773039281
266567267 744830423
338924380 918542055
413001686 717894752
786408307 211692098
280986141 432842000
195582858 921321743
412109607 485887870
262421557 244551274
303481411 585109375
922835159 77375674
276669713 485047938
748493209 63888398
37129726 285918022...

output:

3327
0100001101000111000000111011011100111100001100101011101000000010010111010100001001010100011110010011001001110001010110110010010011010001111000000100101011101000100000100100110000010111010100100000101001110110010111111010101011101011100100001000001010101100001001101011010011110001011101110001110...

input:

2
100 79 3327
0100001101000111000000111011011100111100001100101011101000000010010111010100001001010100011110010011001001110001010110110010010011010001111000000100101011101000100000100100110000010111010100100000101001110110010111111010101011101011100100001000001010101100001001101011010011110001011101...

output:

43372101
204611063
352593757
432842000
142147490
891337416
585109375
743309504
647533065
464964608
876089821
211692098
955710889
971589766
63888398
781195091
748872098
918542055
738134414
271774069
559783342
631668225
32245370
502187994
978371138
563783889
900635155
921321743
760555399
270665755
276...

result:

points 0.8910 ok K = 3327

Test #5:

score: 89.6333
Acceptable Answer
time: 2ms = 1ms + 1ms
memory: 4092kb,3768kb

input:

1
100
326454605 159474960
11647328 932941462
367166680 626258331
846588658 385992166
148602944 380296908
32123445 521548223
146657758 872883623
78417135 361494853
902204073 975297913
50096537 520296997
687284103 420187394
93781442 87808395
503014564 573344902
720903126 546124141
87676450 646360824
9...

output:

3311
0010010001000101111000010100100000110011011110110001110011011011100000111111111000111110001010001100011110001010001001100010111110110110110111000001110100100000011010010001011011011101010110100100010011110001000111100111001010000000100101000110101111000110000011010110011000000001001110100101110...

input:

2
100 79 3311
0010010001000101111000010100100000110011011110110001110011011011100000111111111000111110001010001100011110001010001001100010111110110110110111000001110100100000011010010001011011011101010110100100010011110001000111100111001010000000100101000110101111000110000011010110011000000001001110...

output:

744601533
267129639
871217352
872883623
255371549
162360942
420187394
62984915
242781986
691399852
480380990
521548223
206206675
214089065
546124141
380557861
669664079
385992166
150840342
413877880
634078816
965530575
770169571
451364705
804171981
524846617
166621075
361494853
603970305
891038427
6...

result:

points 0.89633333330 ok K = 3311

Test #6:

score: 88
Acceptable Answer
time: 1ms = 0ms + 1ms
memory: 4080kb,3880kb

input:

1
100
64333280 212072142
621741906 581061751
485561139 692210649
992259436 287935018
247191279 473618369
757620730 140577613
737479792 180977604
404566245 999575096
265846881 11981569
207666352 505750476
304958822 388901054
389584560 428620342
171809402 115660346
324907936 144402645
844495803 791121...

output:

3360
0000001000010110110001011100001100011001101111001000010110100000011111100101000001110101011100000010000011111011101110110110100110110110110010101011110111110100101110111000110010010001010100010101010001010001100101001000100000000100011111000110001001111100011101011000101101110101110011001111000...

input:

2
100 79 3360
0000001000010110110001011100001100011001101111001000010110100000011111100101000001110101011100000010000011111011101110110110100110110110110010101011110111110100101110111000110010010001010100010101010001010001100101001000100000000100011111000110001001111100011101011000101101110101110011...

output:

925952390
770406569
77034978
180977604
957934192
99668862
388901054
858699296
371495636
28514411
68070922
140577613
781757001
847250666
144402645
346058199
267461021
287935018
989151756
348668969
556273495
997895853
95321369
938341707
276009971
101428817
899728485
999575096
385642796
181794009
75258...

result:

points 0.880 ok K = 3360

Test #7:

score: 89.6333
Acceptable Answer
time: 1ms = 0ms + 1ms
memory: 4072kb,3744kb

input:

1
100
38589601 573023388
6635272 692946586
153397181 811034102
859889237 493892802
259205483 364719660
954343124 427626481
959173918 753851930
975496695 577574806
311830132 29056811
509015429 310443549
588209966 697904208
31314024 836756664
249907127 458343750
355938610 284261099
221528639 337802970...

output:

3311
0101000111001110011101000001001110001010110010101100000100011011011110011000111011110000110110000101000000010011100110010101001010100001110100100111111110111000111000011000011110100001101110110111010011000100101001100001110001101100111111001011000101111001101101101010110010101010010011100001000...

input:

2
100 79 3311
0101000111001110011101000001001110001010110010101100000100011011011110011000111011110000110110000101000000010011100110010101001010100001110100100111111110111000111000011000011110100001101110110111010011000100101001100001110001101100111111001011000101111001101101101010110010101010010011...

output:

230017218
565349569
47782129
753851930
678112683
647428660
697904208
283703409
312668984
173256201
644234813
427626481
304813844
912323446
284261099
886592164
929134689
493892802
555567576
65699189
645479813
694103982
65190925
671520247
354050416
976551128
738019464
577574806
813237436
891060967
888...

result:

points 0.89633333330 ok K = 3311

Test #8:

score: 88.6
Acceptable Answer
time: 0ms = 0ms + 0ms
memory: 3820kb,3880kb

input:

1
100
608812690 879292074
479028197 788306143
615995302 841820438
145257256 962764296
602711633 995581697
898256936 448106429
760128150 867194906
843820112 719060821
156799570 629004151
556234422 563271562
355032462 28734192
691911457 345245685
868932163 940932744
589136297 140594459
605248500 81637...

output:

3342
1110011100111011100000101100100010111001100000001100000010011111111101000110011010001100011010101011011101010100111110001101101010111111010010101110001001100011001000111000011011011010111100100000000010111001110000001111101101100011100111000011011111000001111110011111101101010000111001001011000...

input:

2
100 79 3342
1110011100111011100000101100100010111001100000001100000010011111111101000110011010001100011010101011011101010100111110001101101010111111010010101110001001100011001000111000011011011010111100100000000010111001110000001111101101100011100111000011011111000001111110011111101101010000111001...

output:

500331265
566760896
580044819
867194906
560949333
9781752
28734192
263251739
247143049
846291006
332847217
448106429
266605081
382040161
140594459
32445827
364204743
962764296
647363961
549897822
266248054
819012425
609835929
951476639
538336120
158314822
355385207
719060821
493794877
696188978
3014...

result:

points 0.8860 ok K = 3342

Test #9:

score: 88.5667
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 3816kb,4048kb

input:

1
100
221411475 163696773
580081552 897674994
529495152 42484057
439934490 746227851
716122469 137572309
850797298 158711960
820091048 515476547
797154090 246166696
923505280 368103965
246035210 308696941
613434683 955145371
875043135 212559533
205331778 121889189
468477922 194020296
861623799 72521...

output:

3343
0100011100011100111011000101101111100000111111010000001011011100010011011101001001110110110000001001010011011011011011001011110000111001101010000010000100010100000011011011011000101011001001101010110110101000100001110000111101110000100101001010101000001101111001001100001001010010110001001111000...

input:

2
100 79 3343
0100011100011100111011000101101111100000111111010000001011011100010011011101001001110110110000001001010011011011011011001011110000111001101010000010000100010100000011011011011000101011001001101010110110101000100001110000111101110000100101001010101000001101111001001100001001010010110001...

output:

447518344
20372800
820057525
515476547
929148550
975667875
955145371
710181675
270693487
815249231
444426161
158711960
978716476
472823181
194020296
768850245
118243886
746227851
939771652
880147346
23021000
674514174
170878417
120543464
688090699
772795972
659239901
246166696
22324283
62945716
4424...

result:

points 0.88566666670 ok K = 3343

Test #10:

score: 89.3
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 4072kb,3792kb

input:

1
100
19599769 503599235
607852146 743568370
186281835 152620298
14504908 481672793
781288195 362834688
151340700 673227358
631578327 616559846
162406965 868151253
654902334 704640894
506151846 36830214
260055673 991685781
541724792 551734837
725627458 660315138
732278528 433696372
325821250 4876257...

output:

3321
1000101001010101001000111000100101010101000111101111000100110110110110001000111010010110101101011011010111110000000011001111010001010110111101000110100101011111001010100100110111110110001101110101000100010111000001000000110001111001000010110000111110011100000100001010001000000111101010101111110...

input:

2
100 79 3321
1000101001010101001000111000100101010101000111101111000100110110110110001000111010010110101101011011010111110000000011001111010001010110111101000110100101011111001010100100110111110110001101110101000100010111000001000000110001111001000010110000111110011100000100001010001000000111101010...

output:

17522166
203911209
128873662
616559846
5724752
637807633
991685781
667107960
23742057
733808995
34061776
673227358
76723239
80053091
433696372
302174338
804265440
481672793
129338272
820651206
457529317
578437883
142129496
92873118
115024862
323981695
456071005
868151253
79539206
533123847
250920833...

result:

points 0.8930 ok K = 3321

Test #11:

score: 87.7333
Acceptable Answer
time: 2ms = 1ms + 1ms
memory: 3788kb,3748kb

input:

1
100
754728080 615034506
278142947 739166255
431557648 213650106
801076937 12302465
390056764 405912325
958010191 972296266
618096674 290293214
816072144 822111433
114390542 264666411
362376476 262284198
397871046 932447079
740458746 280549044
401344771 621570565
158481121 162119017
575252154 10877...

output:

3368
0000010101010110100100101010100100010000011000101010001001101011010001100110110101111010110000011011011101100111010001001000001000100001111011011110010110100100111100001000110110101000011001111110010011111100010101011000011101010011010110010000111000100100001000100001101110101100100111101100100...

input:

2
100 79 3368
0000010101010110100100101010100100010000011000101010001001101011010001100110110101111010110000011011011101100111010001001000001000100001111011011110010110100100111100001000110110101000011001111110010011111100010101011000011101010011010110010000111000100100001000100001101110101100100111...

output:

956707937
764151542
425056403
290293214
904945055
569744963
932447079
578669827
615355462
437815230
175380679
972296266
707177724
779023842
162119017
102160143
489008046
12302465
71297359
937102868
844790648
930068047
918051016
375684910
653833961
85896778
97899197
822111433
333928660
394182386
2979...

result:

points 0.87733333330 ok K = 3368

Test #12:

score: 89.6333
Acceptable Answer
time: 0ms = 0ms + 0ms
memory: 3776kb,3760kb

input:

1
100
651602369 609971562
405806520 338858725
82461387 773296498
370394604 205907118
83229151 915559769
402520445 634368224
295827147 51732839
850231879 473145268
91650669 793908439
989299809 96921178
907891317 791908538
221803027 446090649
124079152 603405537
739157248 694680954
704470038 219741129...

output:

3311
1001110010110100010001011111011100011101001101111110111110101111101101001001101010101010010010010110110011000100111001110111110000010011001101110010100101111110101100111101000101001111001100100001100110001000001111100111010001010100111001010110011001111101010010111101111000111100010101110100001...

input:

2
100 79 3311
1001110010110100010001011111011100011101001101111110111110101111101101001001101010101010010010010110110011000100111001110111110000010011001101110010100101111110101100111101000101001111001100100001100110001000001111100111010001010100111001010110011001111101010010111101111000111100010101...

output:

304926408
871747385
695719855
51732839
30730873
858053531
791908538
890946266
742114626
147850369
963347495
634368224
56126240
294913872
694680954
413016011
3780006
205907118
980617161
660575727
27667900
592622098
681202212
760457383
415626677
428417886
570655471
473145268
966433960
923765677
553360...

result:

points 0.89633333330 ok K = 3311

Test #13:

score: 88.3667
Acceptable Answer
time: 1ms = 0ms + 1ms
memory: 3788kb,3956kb

input:

1
100
900905485 986849220
865890639 989219769
974980553 815503255
12084595 62574731
234049511 570118116
55567194 907451536
607443488 476001345
441446673 515273718
647029160 196634608
984700195 391421066
387033530 548761294
299636778 162002144
258531148 905788089
99288303 231936743
506688707 46687162...

output:

3349
0111001000010010110100111101100000000111100011000100010110011011101111100000100100111001011010000110111011100111111110110110001101110110110110000101000110111011000101010000010110110110111111011000111111010001010100010010101010000110000100101000110101111111011000100000111111011100100111110010110...

input:

2
100 79 3349
0111001000010010110100111101100000000111100011000100010110011011101111100000100100111001011010000110111011100111111110110110001101110110110110000101000110111011000101010000010110110110111111011000111111010001010100010010101010000110000100101000110101111111011000100000111111011100100111...

output:

806344887
664008030
73690163
476001345
211279038
879930441
548761294
308851136
443343152
782576630
352250016
907451536
584286144
374558469
231936743
760852838
985997701
62574731
372865777
828181419
656826593
577394566
759576483
515637769
769134727
778154760
263932789
515273718
69006606
294577561
498...

result:

points 0.88366666670 ok K = 3349

Test #14:

score: 89.0333
Acceptable Answer
time: 1ms = 1ms + 0ms
memory: 4076kb,3756kb

input:

1
100
100175674 328715935
971481682 194132780
717666444 504666299
330362693 977581115
872779535 597235480
375783505 452186384
419400050 627221988
600872811 553467292
201684227 507815487
95388868 719860800
820903171 665851948
43416948 800556305
277069166 53288802
376279049 298221064
161791895 1888138...

output:

3329
0110010110000000101110101011000010111011011100010111010100110111100100001010101111101111000001001000001100001011110111001011011100101111100010000111011111110101011101011011110110010101111100010011000000100111010011010011001010001111000001010001000000011100011011000100110001101001110100011011111...

input:

2
100 79 3329
0110010110000000101110101011000010111011011100010111010100110111100100001010101111101111000001001000001100001011110111001011011100101111100010000111011111110101011101011011110110010101111100010011000000100111010011010011001010001111000001010001000000011100011011000100110001101001110100...

output:

656202152
38139659
986245811
627221988
262987141
41626531
665851948
721346847
18937813
662860631
348766134
452186384
952646508
719733063
298221064
310596719
287953722
977581115
980528425
123043074
740357729
215128353
275085455
357145189
231768137
968678053
431885039
553467292
654066409
991017403
592...

result:

points 0.89033333330 ok K = 3329

Test #15:

score: 88.2
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 3824kb,3768kb

input:

1
100
155759197 738116086
693067528 594897020
326890902 625583897
248669652 892268604
982863679 666422296
851843372 868420150
318485019 643582119
817328291 563713715
147817474 54748668
839462496 907507551
485479383 25930860
669573094 752904913
226916686 37390772
111822444 292076901
593570288 9599256...

output:

3354
1000111011000111111010111000010011011101011101011000100111111100110011100110001001101110010111010111100011000110001000011001111010111111101011101110111010000110111001101111110000010110101001010011010111000001010001001001000110011000111111101110100001011100110000101001011101100001101101100010001...

input:

2
100 79 3354
1000111011000111111010111000010011011101011101011000100111111100110011100110001001101110010111010111100011000110001000011001111010111111101011101110111010000110111001101111110000010110101001010011010111000001010001001001000110011000111111101110100001011100110000101001011101100001101101...

output:

237700952
431918470
552117997
643582119
179644804
592543520
25930860
71700147
515536454
240714551
904270220
868420150
409900083
236315209
292076901
682237796
969917168
892268604
730750810
677248102
964094246
746774159
915185427
483386475
303613984
892436193
535058636
563713715
208906352
365661664
70...

result:

points 0.8820 ok K = 3354

Test #16:

score: 88.6333
Acceptable Answer
time: 2ms = 2ms + 0ms
memory: 3836kb,3816kb

input:

1
100
528691319 91831880
386349345 731326576
21176008 940098540
325859753 762337780
713581844 897308394
774875332 625809049
252347069 294035274
623069253 468083716
648169883 510534328
99296629 772471648
385338480 58002281
223045398 430841708
313950768 22827747
173102112 767986059
540475972 562649334...

output:

3341
1110111011011111011100000010000100100101001001100101101000101100101010010101010011101100101111110011100101111101011001011110010000100000111000010100111010011101011000000101011001101111000001001011011011011111110000111100101101000110010001011000111011010000011011011111010100000111011111000001011...

input:

2
100 79 3341
1110111011011111011100000010000100100101001001100101101000101100101010010101010011101100101111110011100101111101011001011110010000100000111000010100111010011101011000000101011001101111000001001011011011011111110000111100101101000110010001011000111011010000011011011111010100000111011111...

output:

525791347
67606394
423041096
294035274
505042001
36069272
58002281
486356778
736546059
708625946
554916860
625809049
239334507
588411226
767986059
447213639
540326718
762337780
504417370
41031618
377948179
599950989
278829818
167509922
486272562
158889968
701081566
468083716
585296033
674626268
7669...

result:

points 0.88633333330 ok K = 3341

Test #17:

score: 88.7333
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 3780kb,3740kb

input:

1
100
670714199 899616316
329702868 22625676
609441993 414274788
231301804 982523317
499797027 829951970
554440084 606392830
416502025 91330445
765840045 291414099
955527229 697408403
468888699 842546173
140134565 404507934
469199432 692339096
392093128 681468648
224453201 253441757
536866309 687113...

output:

3338
0010000000001010110110111000000010010101110111111110001011001001000010010101111011010001111111100000110010010001010000010101100110001110010111111010101001001110111010011000110001010001001000001001111111101011011010011101110101011001110011111000001010110001000010110000011000000011011101010010110...

input:

2
100 79 3338
0010000000001010110110111000000010010101110111111110001011001001000010010101111011010001111111100000110010010001010000010101100110001110010111111010101001001110111010011000110001010001001000001001111111101011011010011101110101011001110011111000001010110001000010110000011000000011011101...

output:

242761459
143380783
210207234
91330445
429281488
593964600
404507934
994543054
389733156
263001270
548956961
606392830
332393935
547574592
253441757
463394561
905379537
982523317
900985807
641084668
253229006
698233960
999741433
286544104
597913890
717679349
758596846
291414099
465760688
831854537
3...

result:

points 0.88733333330 ok K = 3338

Test #18:

score: 88.5333
Acceptable Answer
time: 1ms = 0ms + 1ms
memory: 4076kb,3768kb

input:

1
100
275061606 289457664
693063527 749795396
795050156 134138686
981588711 937513908
429027101 860895914
674570083 891634484
550874890 279984285
582813425 847536233
321204048 609521529
291674417 859403227
725419330 333924634
132857229 577840142
557763992 970692209
811676515 114428543
101877420 3158...

output:

3344
1011010111101010011100010100001111100100000100000110000100010011011100011101110111000000101101110011011001001001010011000001110001011100010110001100101011100111101100110001111011000011100010100010011101000110010100010110010111000111011110111000001110110101000110010000010111101110000000101101101...

input:

2
100 79 3344
1011010111101010011100010100001111100100000100000110000100010011011100011101110111000000101101110011011001001001010011000001110001011100010110001100101011100111101100110001111011000011100010100010011101000110010100010110010111000111011110111000001110110101000110010000010111101110000000...

output:

382108052
879750157
37994005
279984285
580337233
18231300
333924634
234260705
715271084
344172931
938975031
891634484
144724709
373096103
114428543
956849472
342941235
937513908
479067941
598876546
9034105
41691365
182789857
131813075
579935334
765864325
601678407
847536233
328128741
947656737
10183...

result:

points 0.88533333330 ok K = 3344

Test #19:

score: 88.0333
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 4068kb,3896kb

input:

1
100
470536077 756757121
698892841 113862517
391881103 169085283
574848268 834285768
83385059 209666273
443574343 389990921
771772748 681164066
330356183 577452798
715424487 88461370
302878747 916053614
615497987 409959796
116516935 580821406
983941553 319204899
451405325 262835243
98691093 4489770...

output:

3359
1111011101010101110000001011101000101010001010011101100110001011011011011000000101001100110110001011010111110110000011001011111110100010011010010101010001100010010100111001010000001001011101001000110001000010110111001110000001101100010110101010001000100100110100101000101110001111100100110001101...

input:

2
100 79 3359
1111011101010101110000001011101000101010001010011101100110001011011011011000000101001100110110001011010111110110000011001011111110100010011010010101010001100010010100111001010000001001011101001000110001000010110111001110000001101100010110101010001000100100110100101000101110001111100100...

output:

528747963
959190249
718941756
681164066
467466808
726056672
409959796
998200951
89671985
75316879
739174254
389990921
422960743
502293847
262835243
197165052
808221348
834285768
984153761
424350863
561256918
656088826
819439861
743282063
819577672
220146817
544150179
577452798
818978473
950820104
13...

result:

points 0.88033333330 ok K = 3359

Test #20:

score: 88.4
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 4076kb,3796kb

input:

1
100
857972746 134585349
760010510 2409930
829735729 992224127
440669822 213659303
885149400 813615513
56577893 296741031
868626948 249885189
796120839 848097683
319287857 593262418
113573269 310951877
159423015 689854466
604382512 678191352
662333203 970475275
41537552 369712985
896091462 80987399...

output:

3348
1001011010101001101011101010001101101010001100111011010110101100100101101111101010011101100011001110010111100001000011111100101110010101111101001111100011100011010010001000101000000110100001100111111001101010010011100011100010000010111010101110101100000001000011111001100100001000100001010001101...

input:

2
100 79 3348
1001011010101001101011101010001101101010001100111011010110101100100101101111101010011101100011001110010111100001000011111100101110010101111101001111100011100011010010001000101000000110100001100111111001101010010011100011100010000010111010101110101100000001000011111001100100001000100001...

output:

804546071
438874305
438151180
249885189
401629802
750923475
689854466
301429802
387560367
155851954
6936429
296741031
730588729
641027582
369712985
853514377
442079545
213659303
629911625
116708306
685696220
822079954
658493553
291754485
411862892
377892525
901098253
848097683
101876279
829010531
42...

result:

points 0.8840 ok K = 3348

Test #21:

score: 88.3667
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 3784kb,3872kb

input:

1
100
338282351 535547274
750971852 174091841
561253347 576036946
56873245 859929495
969725293 454521472
369256223 469692455
764245447 421478570
69490101 484398194
511848702 543549274
795380426 373214417
703131114 43647426
470419094 661670484
888281054 847964250
582810624 530062905
9858387 17503621
...

output:

3349
0000000000001111011010110100100111111001011011001011001010101010001001101001110011000000100101100101100101010111111111100010111001010000000101001110111010001101100101001011110100101110011001001100101000110001101010111011000111011101101111000010110110100000101101100101110010000111101101010011110...

input:

2
100 79 3349
0000000000001111011010110100100111111001011011001011001010101010001001101001110011000000100101100101100101010111111111100010111001010000000101001110111010001101100101001011110100101110011001001100101000110001101010111011000111011101101111000010110110100000101101100101110010000111101101...

output:

224507328
770100728
519728537
421478570
118701838
90587740
43647426
704195951
382793454
96937647
813071399
469692455
956946168
981902632
530062905
910982983
829361117
859929495
605032370
744119805
488026834
603040517
420827981
488277929
504604368
932579570
161296202
484398194
10047192
920152901
1051...

result:

points 0.88366666670 ok K = 3349

Test #22:

score: 88.5333
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 3828kb,3740kb

input:

1
100
130346006 891277451
885624488 257660768
148463654 540363656
110899930 346826439
698283177 665412444
994380771 198320684
778409823 541781037
745591948 343969889
919211689 712095403
601055685 905001997
358086203 837731489
672966517 216082867
24812745 420306523
57050251 310792238
247206563 475591...

output:

3344
1000110001001011011011101110011001100100000010110001110100111110000001100001101110011110110110000101010100010010100111010110010100001010011100100111110101100111001101101100111000100010110001011101101001111010101100001001100111011010010010100011001001010000100001100011111011010101100001000111010...

input:

2
100 79 3344
1000110001001011011011101110011001100100000010110001110100111110000001100001101110011110110110000101010100010010100111010110010100001010011100100111110101100111001101101100111000100010110001011101101001111010101100001001100111011010010010100011001001010000100001100011111011010101100001...

output:

656343932
684168382
769585519
541781037
468507179
735145247
837731489
583535496
684793051
634167649
525100749
198320684
439196264
262549584
310792238
268347712
771030767
346826439
466407071
404696628
739808802
917494906
43705634
458958901
632146165
417638157
84813667
343969889
798218178
614579243
64...

result:

points 0.88533333330 ok K = 3344

Test #23:

score: 89.4
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 3848kb,3752kb

input:

1
100
727353765 540226289
198728094 766386773
357131756 478519307
988591322 666204558
622299099 662757533
526181560 633002809
768119020 439579332
304399500 927131671
54245905 582897180
437454576 979186091
167429496 970050114
517098789 559461657
368905545 99338682
33385857 931761781
68394178 77881384...

output:

3318
1010010011100100001011000100011100000000000001011001001100111000111101000010100111001110000110111111000101000000000111100001100010111001100010101101000110101000010001010100111010001000010000001100001110101000111011011001111001001101000000101001101001010001110110001000100111001001010110000101001...

input:

2
100 79 3318
1010010011100100001011000100011100000000000001011001001100111000111101000010100111001110000110111111000101000000000111100001100010111001100010101101000110101000010001010100111010001000010000001100001110101000111011011001111001001101000000101001101001010001110110001000100111001001010110...

output:

637707074
926530
819970639
439579332
968299971
694485705
970050114
210282009
993494804
971480757
689839964
633002809
809612133
875781636
931761781
114357809
426541289
666204558
360491482
232189192
455981622
14973200
829830701
691605944
296245432
645800065
518516007
927131671
472579938
459967353
5315...

result:

points 0.8940 ok K = 3318

Test #24:

score: 89.6
Acceptable Answer
time: 0ms = 0ms + 0ms
memory: 3816kb,4056kb

input:

1
100
516669880 692841746
537032986 548707172
768481811 330616621
565529569 204235345
568604397 276406459
531260376 966386991
470728934 288381852
736546167 435216158
101516449 464172040
625913894 488536307
116887383 347627700
758664574 131095502
389606580 84082160
373851139 353684419
794964985 82206...

output:

3312
1100000010101100110110010011111111110000110000010010110010111100011010111011100100110000111010100101110100110011011111111110001011000100011001101100000110001010011100000000010100100110101001001010100101000101111000001111100101111101001101110010111110000110101111011111100101010100100111101011110...

input:

2
100 79 3312
1100000010101100110110010011111111110000110000010010110010111100011010111011100100110000111010100101110100110011011111111110001011000100011001101100000110001010011100000000010100100110101001001010100101000101111000001111100101111101001101110010111110000110101111011111100101010100100111...

output:

824265694
823080244
799670389
288381852
169933132
403273887
347627700
448695924
131314426
313129942
213235568
966386991
612384921
431273645
353684419
940366236
412241121
204235345
686356384
543442146
379280891
109609808
975619138
944832568
775109683
613502168
617479713
435216158
666549936
277678005
...

result:

points 0.8960 ok K = 3312

Test #25:

score: 88.7333
Acceptable Answer
time: 1ms = 1ms + 0ms
memory: 3984kb,3748kb

input:

1
100
372104321 661333761
926919776 579976882
403232435 494262953
446358648 437141002
47453478 652538571
500378800 637915335
236300111 106901258
116478562 352343485
519690966 510494272
884586941 748751699
589183960 469068835
309223864 294984914
276227690 364108467
922165060 297950392
45400397 686943...

output:

3338
0100000110100111011101011110010001011110100110010101111000100100001000101101001101001111001001110110010101000001011100100001000011000000001001100001101101100111100011111000001101101110011101000001010001011110100011000101000100100010011001101110100001101011101101101001111101010001001100100100111...

input:

2
100 79 3338
0100000110100111011101011110010001011110100110010101111000100100001000101101001101001111001001110110010101000001011100100001000011000000001001100001101101100111100011111000001101101110011101000001010001011110100011000101000100100010011001101110100001101011101101101001111101010001001100...

output:

749880619
80543316
586138899
106901258
219907616
408787218
469068835
396524270
333555991
531826730
918802316
637915335
140716275
194883708
297950392
85568567
521067667
437141002
647729371
523149256
335538435
853017270
931231977
648867380
360880023
435128215
632685180
352343485
133234415
605658882
67...

result:

points 0.88733333330 ok K = 3338

Test #26:

score: 88.4333
Acceptable Answer
time: 1ms = 0ms + 1ms
memory: 3916kb,4052kb

input:

1
100
771595997 319786827
412811499 817307270
738505239 885061434
985904063 437562537
445352259 411925181
123822945 823894119
888835788 999087562
646220704 82172817
81547928 89237739
599934026 710756331
6101115 374839154
361877824 345100503
149063202 933188075
703658682 691533365
158847800 107227001...

output:

3347
1111001010100101010000010110100001011011011110011000000101110110001000110111000001000111111011110011101011110101011110101100010001100101010101100111001101000011011011110001111000010101010110011100000100100110100111101001011101100011010000010001110111010101010010001111010101101111010110000101111...

input:

2
100 79 3347
1111001010100101010000010110100001011011011110011000000101110110001000110111000001000111111011110011101011110101011110101100010001100101010101100111001101000011011011110001111000010101010110011100000100100110100111101001011101100011010000010001110111010101010010001111010101101111010110...

output:

765552682
786058369
301260795
999087562
612183861
193509014
374839154
507856834
741140138
286118761
208098625
823894119
870326141
644082047
691533365
575204482
824337497
437562537
896172427
445148558
118382861
878135225
407536487
510560011
535710878
111854461
10749392
82172817
107651473
954777140
40...

result:

points 0.88433333330 ok K = 3347

Test #27:

score: 87.9667
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 3832kb,3764kb

input:

1
100
206035075 511295878
943493371 350467904
992398940 364769667
189487358 350467904
770852642 511295878
696317149 511295878
211799514 747768455
687279973 364769667
991712428 350467904
742823341 350467904
560412664 747768455
552146681 747768455
201447729 249391801
68952867 249391801
324496155 36476...

output:

3361
0011111000010000001011101101110001110010101001110101010110101110110111000000001011101101110001110010101001110101010110101110110111001001110101010110101110110111001110000101010000010010010011010000001011101101110001110010101100000110001111101111011010100000001011101101110001110010100110000110000...

input:

2
100 79 3361
0011111000010000001011101101110001110010101001110101010110101110110111000000001011101101110001110010101001110101010110101110110111001001110101010110101110110111001110000101010000010010010011010000001011101101110001110010101100000110001111101111011010100000001011101101110001110010100110...

output:

249391801
249391801
747768455
747768455
249391801
249391801
747768455
249391801
364769667
747768455
364769667
511295878
511295878
747768455
249391801
511295878
747768455
350467904
249391801
364769667
511295878
511295878
350467904
249391801
249391801
511295878
249391801
364769667
747768455
350467904
...

result:

points 0.87966666670 ok K = 3361

Test #28:

score: 88.2
Acceptable Answer
time: 2ms = 1ms + 1ms
memory: 4024kb,3992kb

input:

1
100
38846592 590301525
766125667 583955748
147163223 473282891
47853599 84365741
966765100 84365741
767572143 473282891
112595241 473282891
102598295 84365741
855963947 583955748
970219272 473282891
580798626 729529201
969377524 729529201
28800277 583955748
103065213 84365741
964977691 583955748
3...

output:

3354
0001000001000010010010101110011100110100010010010010101110011100110100011011010110001010111000001010001000111011011101110111101101011010101010010010111101001100011000111011011101110111101101011101001010011101101011000011100010010010101110011100110100011010101010010010111101001100011010101010010...

input:

2
100 79 3354
0001000001000010010010101110011100110100010010010010101110011100110100011011010110001010111000001010001000111011011101110111101101011010101010010010111101001100011000111011011101110111101101011101001010011101101011000011100010010010101110011100110100011010101010010010111101001100011010...

output:

729529201
84365741
729529201
473282891
583955748
590301525
729529201
583955748
583955748
729529201
583955748
473282891
729529201
590301525
84365741
84365741
729529201
84365741
590301525
729529201
729529201
84365741
583955748
84365741
473282891
729529201
590301525
84365741
84365741
583955748
72952920...

result:

points 0.8820 ok K = 3354

Test #29:

score: 89.2
Acceptable Answer
time: 3ms = 2ms + 1ms
memory: 3844kb,3964kb

input:

1
100
477271109 449442777
446718189 276977366
466140087 216878887
784932585 449442777
479123602 276977366
630426762 216878887
239787459 449442777
634896974 449442777
708961222 449442777
842146301 54046568
656380589 276977366
528549690 54046568
68980391 54046568
18291326 276977366
807959596 276977366...

output:

3324
0111001111000010100001110101010011100111000110101101101010010000010000100110101101101010010000010000101001101111001111100100110101100010100001110101010011100111000010100001110101010011100111000010100001110101010011100111000001011011110101000111001100000110101101101010010000010000100110101101101...

input:

2
100 79 3324
0111001111000010100001110101010011100111000110101101101010010000010000100110101101101010010000010000101001101111001111100100110101100010100001110101010011100111000010100001110101010011100111000010100001110101010011100111000001011011110101000111001100000110101101101010010000010000100110...

output:

276977366
449442777
449442777
449442777
449442777
242396692
276977366
242396692
54046568
54046568
216878887
216878887
449442777
54046568
276977366
276977366
54046568
449442777
54046568
449442777
242396692
242396692
54046568
242396692
216878887
242396692
242396692
449442777
216878887
216878887
449442...

result:

points 0.8920 ok K = 3324

Test #30:

score: 0
Runtime Error

input:

1
100
585065483 112535650
608937343 327454770
624137583 327454770
629362329 327454770
644440246 226319000
760047072 813169447
528034354 633359692
95539762 815721144
785118862 681153074
998922749 951454394
601779042 493831708
453071066 197965269
81706587 292630540
605661446 681153074
186765866 622304...

output:


result: