QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#18786#383. 蚯蚓排队Qingyu100 ✓938ms97996kbC++202.3kb2022-01-26 23:05:182022-05-06 02:35:58

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-06 02:35:58]
  • 评测
  • 测评结果:100
  • 用时:938ms
  • 内存:97996kb
  • [2022-01-26 23:05:18]
  • 提交

answer

#include <cstdio>
#include <algorithm>

const int maxn = 4e5, maxm = 2e7, MOD = 998244353;
typedef int arrn[maxn], arrm[maxm];

int tot = 1;
arrn v, ls, rs;
arrm str, w, s[6], pre;

inline int nextInt() {
  register int a;
  register char c, f = 0;
  do c = getchar(); while (c < '-');
  if (c == '-') f = 1, c = getchar();
  a = c ^ 48;
  while (47 < (c = getchar()))
    a = (a << 3) + (a << 1) + (c ^ 48);
  return f ? -a : a;
}

inline int rect(int c, int k) {
  return s[c][k] != 0 ? s[c][k] : (s[c][k] = ++tot,
                                   pre[tot] = s[c][pre[k]],
                                   tot);
}

int main() {
  int n = nextInt(), m = nextInt();
  for (int i = 1; i <= n; ++i) {
    v[i] = nextInt() - 1;
    if (s[v[i]][1] == 0) {
      s[v[i]][1] = ++tot;
      pre[tot] = 1;
    }
    ++w[s[v[i]][1]];
  }
  while (m--) {
    int operation = nextInt();
    if (operation == 1) {
      int a = nextInt(), b = nextInt(), t = 0, p;
      rs[a] = b, ls[b] = a;
      for (int i = a; t < 50 && i != 0; i = ls[i])
        str[++t] = v[i];
      std::reverse(str + 1, str + t + 1);
      p = t;
      for (int i = b; p - t < 50 && i != 0; i = rs[i])
        str[++p] = v[i];
      for (int i = 2; i <= 50 && i <= p; ++i) {
        int x = 1, j = std::max(1, t - i + 2);
        for (int k = i; --k; ++j) x = s[str[j]][x];
        for (; j <= p && j - t < i; ++j) {
          x = rect(str[j], x);
          ++w[x];
          x = pre[x];
        }
      }
    } else if (operation == 2) {
      int a = nextInt(), b = rs[a];
      for (int i = 1, k = a; i < 50 && k != 0; k = ls[k], ++i) {
        int x = 1;
        for (int p = k, j = 1; j <= 50 && p != 0; p = rs[p], ++j) {
          x = s[v[p]][x];
          if (j > i) --w[x];
        }
      }
      rs[a] = ls[b] = 0;
    } else {
      int k = 0;
      char c;
      while ((c = getchar()) < 48);
      while (c > 47)
        str[++k] = (c ^ 48) - 1, c = getchar();
      int ans = 1;
      int t = nextInt();
      for (int i = 1, x = 1; i <= k; ++i) {
        if (s[str[i]][x] == 0) {
          ans = 0;
          break;
        }
        x = s[str[i]][x];
        if (i >= t) {
          ans = 1ll * ans * w[x] % MOD;
          x = pre[x];
        }
      }
      printf("%d\n", ans);
    }
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 4
Accepted
time: 1ms
memory: 3600kb

input:

1 998
2
3 4 1
3 6 1
3 6 1
3 5 1
3 3 1
3 6 1
3 4 1
3 2 1
3 3 1
3 5 1
3 6 1
3 2 1
3 6 1
3 6 1
3 4 1
3 1 1
3 2 1
3 1 1
3 4 1
3 6 1
3 1 1
3 1 1
3 1 1
3 1 1
3 1 1
3 4 1
3 4 1
3 3 1
3 5 1
3 3 1
3 2 1
3 1 1
3 4 1
3 6 1
3 1 1
3 1 1
3 1 1
3 1 1
3 4 1
3 2 1
3 3 1
3 1 1
3 6 1
3 6 1
3 4 1
3 5 1
3 1 1
3 2 1
3 4 ...

output:

0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
1
0
1
0
1
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
1
0
0
0
0
1
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
1
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
1
0
1
0
0
0
0
0
0
0
1
0
0
0
1
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

ok 998 lines

Test #2:

score: 4
Accepted
time: 2ms
memory: 3668kb

input:

20 36
1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1
1 1 15
1 20 8
1 6 13
1 12 14
1 8 16
1 18 10
1 15 20
1 11 5
1 3 18
1 2 12
1 10 19
1 5 3
1 9 4
1 4 1
1 16 2
1 14 17
1 17 11
1 7 6
1 13 9
3 11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 9
3 21111111111...

output:

986314077
44443331
692899615
733474581
500292333
100000
74890016
217787087
725944917
725944917
580570788
224019031
982023376
958346178
492051342
721419738
26617260

result:

ok 17 lines

Test #3:

score: 4
Accepted
time: 10ms
memory: 3680kb

input:

150 2000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1...

output:

1
1369
59319
111149056
579076096
75497441
696218117
0
138412032
4096
49664

result:

ok 11 lines

Test #4:

score: 4
Accepted
time: 2ms
memory: 3692kb

input:

500 508
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

62
86
103
111
11449
1
7301384
170275611
251731360
15232

result:

ok 10 lines

Test #5:

score: 4
Accepted
time: 3ms
memory: 3728kb

input:

1000 2000
1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 ...

output:

75497471
557842400
7776
488304148
20914171
382533613
813694974
977736708
788660220
522665847
646770514
697001913

result:

ok 12 lines

Test #6:

score: 4
Accepted
time: 60ms
memory: 30588kb

input:

50000 52913
2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 3 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 2 1 1 1 1 1 1 ...

output:

100663294
52953600
3350906
229765322
887621869
940273577
556568575
77125694
828
666008243
367790545
411163649
633970710
763354829
130586370
3360000
715174225
448852005
533570000
1349190
221848871
15240960
10125
133382700
88491522
37260000
477652581
319871250
33944064
778196802
735766300
611140495
39...

result:

ok 1089 lines

Test #7:

score: 4
Accepted
time: 29ms
memory: 3924kb

input:

50000 50367
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

73850210
335399794
177349861
530147760
679864040
408420629
977110945
266797286
731604775
908330181
195026826
107628602
517966089
543605781
713618257
872105513
462825074
272044043
792449213
633863169
626814262
299821169
345000831
61315514
177692186
274156588
341079525
388184505
244861282
598888666
40...

result:

ok 450 lines

Test #8:

score: 4
Accepted
time: 55ms
memory: 25316kb

input:

50000 50451
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

3564288
1
1
1
1
2880
1
1
1
1
1
2
1
1
1
1
1
1
1
1
2048
1
128
387325950
1
811745279
124
40
1
72
80
1125000
288
4
2
2457600
1
1
1
8
4
0
6
1
1
1
1
1
1
16512
933120
1
7962624
1
1
12
1
1
1
1
1
1
19200
1
9
1
3456
1327104
9
1
1
1
384
1
219240
1
1
1
536870692
1
1
1119744
1
1
16
1
1
2592000
4590432
905887742
...

result:

ok 498 lines

Test #9:

score: 4
Accepted
time: 80ms
memory: 32464kb

input:

50000 52353
1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 3 ...

output:

1
1
1
1
1
12
1866240
0
1
1
32
32
119439360
182878207
1
108000
1
1
1
1
1
1
1
1
704642628
1
432
1
55296
54675
1
1
15129
66528
703624188
768
0
1
1959552
64
1
96
2
1
1
196608
845091137
1
1
64
1
1
1
1
1
224
1
972
579862517
1
4
1
96
737280
16
270978048
1
0
4
1
1
1
3888
1
46656
18
20
16
1
1
1280
1
1
1
2048...

result:

ok 488 lines

Test #10:

score: 4
Accepted
time: 120ms
memory: 28344kb

input:

50000 72349
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 2 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 ...

output:

1
1
11
1
1
1
1
12
1
1
12057136
1
722677759
1
1
926449744
1
5270
485529040
1
4
216
1
1
1
336
1
1
1
1
1
1
4
1
1
1
18000640
1
1
388
4
1
1
1
1
1
256
32845824
1
850208
1
1
2
404458118
1
8
1
1
1
1
1
1
1
4608
2
37748736
1536
1
1
256
1
128
1
18
134369280
1
1
1
1
1
1
131072
1
5
2304
4
1024
39
432
29196288
1
...

result:

ok 22350 lines

Test #11:

score: 4
Accepted
time: 174ms
memory: 39572kb

input:

50000 74648
1 1 1 1 1 1 1 2 1 1 1 2 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 3 1 1 1 1 ...

output:

2
1
1
1
1
1
1
828609048
1
94089600
1
16
3
1
6962
1
1
1
4
768
2
1
4
86016
2
1
4480
1
1
1
79626240
1
1
1
1
1
1
1
32
1
1210104
1
1
1
1
1
1
82944
128
870912
96
1
640
1
3
38338560
1
1
4
8
1
1
1
724565999
1
1
139747327
5598720
233046014
1
55427328
1
27648
216
64
36000
316155013
1
1
1
1
1
1
974848
12672
17...

result:

ok 22654 lines

Test #12:

score: 4
Accepted
time: 87ms
memory: 35292kb

input:

100000 102412
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 2 3 1 1 1 1 1 3 1 1 1 1 4 1 1 1 1 1 2 1 1 1 1 1 2 1 3 1 1 1 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1 ...

output:

640458633
60963840
897933587
628097584
722400
418906108
982543771
300008345
996497641
865276065
302221656
40365
900843246
853893119
31214995
831911896
924
2151
16685460
406508583
656801788
454150925
834562506
486999764
260494588
605515982
953400199
52140
7530240
489126
74018880
712685373
563372007
6...

result:

ok 1834 lines

Test #13:

score: 4
Accepted
time: 56ms
memory: 4080kb

input:

100000 100656
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

198290936
992475757
405123071
964895911
71655934
628083161
956765929
18403623
985924788
239349881
404782937
623344687
691801117
212980600
855727768
238671922
506003980
120143114
961389211
638804306
353001491
476016952
374730674
483348327
231068352
933469750
134888160
860558795
462702394
901108431
85...

result:

ok 919 lines

Test #14:

score: 4
Accepted
time: 121ms
memory: 45128kb

input:

100000 100808
1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 2 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 3 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 2 1 1 1 ...

output:

1
1
1
2002
24576
1
16
9072
1
58719409
1
1
32
4
201553920
32
5760
16
1
1
192
1
1
1
1
1
1
1
27648
1
244687500
1
1
17
1
32
252887040
1
1
1
12
5660
16
1
2
648
7
1
182020608
2
7526400
1
1
1
1
1
18
1
1
1
881795200
4608
1
10450944
848
4224
1
1
1
1
1
1
1
16
5971968
3
1
486202500
1
1
71385600
1
1
1
1
4
13271...

result:

ok 989 lines

Test #15:

score: 4
Accepted
time: 138ms
memory: 50112kb

input:

100000 102784
1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 3 1 1 3 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 3 1 1 2 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 2 1 1 1 1 1 1 2 1 3 1 1 1 ...

output:

1
1
1
1
64
8
1
1
1
1
1
1
1
1
1
1
20528640
256
1
1
1
1
1
1
4788
8
1
282920935
1
1
1
1
1
6
16
1
1
1
1
1
1
1
2
4608
1
1
1
16
3969
1
216
1
689962967
1
1
1
1
1
1
1
24
18
1
124416
1
160380000
126
2
1
1
1
896000
921600
96
0
396477100
641520
12
1
1
128
1024
4
312552757
1
1
1
8
3456
1
9
1
1
1
1
1
1
723384316...

result:

ok 1017 lines

Test #16:

score: 4
Accepted
time: 293ms
memory: 48528kb

input:

100000 144773
1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 2 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

1
1
1
512
1
1
1
707788800
1
1
65664
1458
1
12
1
1
5591040
1
1
1
135780823
1
1
18
5603328
1
729
209952
1
1
1
176359680
576
256
1
2
1
1
1
1
1
1
6750
1
1
2592
1
90699264
1
1
1
8
1
1
1
128000
2939328
16
1
1
1
1
1
10752000
32
1
128
24
174960
1
49152
196608
5184
1
1
1
949453982
0
663552
161480699
1
0
1
46...

result:

ok 44774 lines

Test #17:

score: 4
Accepted
time: 384ms
memory: 59460kb

input:

100000 147055
1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 ...

output:

1
1
6144
156826282
1
1
1399680
6
960
1
654310356
462
1
116
1
1
1
1
1
36
1
1
10077696
31104
178
58786517
1
9261
64
57600
1
1
1
1
1
1
1
1
1
1
1
7
6553600
1
1
1
1
2
1
6
1
1
621
6144
9129120
1
1
1
3520
2
1
810
4
91402195
1
6553600
1
8064
1
4
48
1
1
884736000
43740
1
327680
262144
1
318504960
120932352
8...

result:

ok 45065 lines

Test #18:

score: 4
Accepted
time: 399ms
memory: 87344kb

input:

200000 399780
1 3 3 1 1 1 1 1 1 1 3 1 1 2 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 2 2 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 2 3 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 ...

output:

965545644
517982843
811335593
206826568
316282367
25769427
990412672
851334466
734320572
835132994
682948162
241464885
678696149
653734751
130654691
135078617
44817012
12459586
677166287
73790001
506138083
432849544
262906691
31612387
56822326
227256386
828790982
401372203
293848612
704938609
130429...

result:

ok 199781 lines

Test #19:

score: 4
Accepted
time: 476ms
memory: 96712kb

input:

200000 401819
1 1 1 1 1 1 1 2 1 1 1 2 1 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 3 1 1 2 1 1 1 1 1 ...

output:

130116983
977674623
374790962
256046139
132779421
101017502
837226439
633310464
22039359
358766271
982950410
663054881
223626954
928022291
132771200
520138402
193069461
635524060
851110046
938145942
339111862
477458229
875301563
733336778
330150311
645636343
594675245
482804857
260698992
533011020
2...

result:

ok 199864 lines

Test #20:

score: 4
Accepted
time: 101ms
memory: 26092kb

input:

200000 197059
1 1 1 1 1 1 1 2 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 2 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 2 2 2 1 1 1 1 1 1 1 1 1 2 1 1 1 ...

output:

54516
244953
46233460
128801250
134400
719940
685737104
21384
750639403
464045609
29750
959200355
173352960
39936
227749635
655537152
726856
242611200
4533256
1116
398597718
659570749
91661774
573395515
887046141
27904
791688374
83698941
35704800
96682689
397539053
51817713
505852800
812207381
23057...

result:

ok 3981 lines

Test #21:

score: 4
Accepted
time: 98ms
memory: 5100kb

input:

200000 201065
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 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:

80053730
332102092
932233665
209628971
444572055
852281705
797328387
653295229
586033964
933138118
663205669
801373881
918412965
222472001
292879203
11759307
295061778
463499204
662575122
262664612
620722766
947907440
118602298
76664217
338857529
406009104
829198833
888783427
643654271
606259692
848...

result:

ok 1822 lines

Test #22:

score: 4
Accepted
time: 301ms
memory: 82792kb

input:

200000 201611
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 4 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 2 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 2 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 3 ...

output:

1
1
11520000
121569278
1
1
362880
1
1
45554400
463704
16
1
1
1
215221492
1
1
1
1
13824
1
1
1
1
279936
144
4
7303448
256
4
32
286654464
4
1
311040
1
1
1
1
1
1280
1
1451520
288
1
1
1
313600
1
1024
1
0
1
1
27000
73920
124178832
1
45416448
256
1
840
1
5
4
1
1
2
2
1
3194640
1
1
1
500
343932863
8
1
1
32
2...

result:

ok 2041 lines

Test #23:

score: 4
Accepted
time: 258ms
memory: 84204kb

input:

200000 203548
1 1 1 1 1 1 1 1 1 1 1 3 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 3 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 6 1 1 1 2 1 1 1 1 1 ...

output:

792
1
1
1
1
1
1
2
1
1
1
1
18432
64
2
82944
1
1
1
1
1
1
1
13899600
995328
1
1
2916
128
1
9216
1
1
4096
1
34560
1
1
15360
1
1
972549866
0
1161216
829947506
444923119
984960
1
95760
1
33554432
1
768
1
1
42467328
7
1
1
1
1
311
2
1
1
42120
1
1
1
1
559872
395278570
1
31744
20
1
1
19200
1
1
1
1370880
8
1
1...

result:

ok 2055 lines

Test #24:

score: 4
Accepted
time: 653ms
memory: 89728kb

input:

200000 289562
1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 3 1 1 4 1 1 1 1 1 2 3 1 1 1 1 1 1 2 1 1 1 1 3 1 1 1 1 1 2 1 1 1 1 1 3 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 5 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 1 4 1 1 ...

output:

384
2
1
4
1
16
1
1
6
768
1
1
1
1
1
1440000
1
16
1
1
1
64512
243
2
256
1
64
40
1
108
1
1
1
1064448
1
1
1
168000000
540
1
864
4
1
1
8
1
45619200
8
1
1
4
698777413
1
1
40
1
1
1
377487360
1
1
2548520
1
1
3840
570006972
1
1
3064
1
1
27
73656
3
662961789
96
295372210
896547420
352321179
1
41472
24
14
1
85...

result:

ok 89563 lines

Test #25:

score: 4
Accepted
time: 938ms
memory: 97996kb

input:

200000 291554
1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 3 1 2 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 2 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 3 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 2 1 2 2 1 1 1 2 ...

output:

1
1
1
2
1
452391422
32
1
1
1
1
1
8
186624
1
1
183140352
1
1
62099136
1
4
1
1
402408
5308416
1
1
1
1
432
1
512
1
1
1
1
1
8
1
1
1
990115959
1
1
1
1
234880381
76800
1
486
55296
1
16
1
1
1
1680
42758116
1
33524
1
1
2
332398588
1
24
1
576
1
2880
1
1
1
1
1
954895749
4600
562036729
1
1
1
1
589824
1
7201584...

result:

ok 89571 lines

Extra Test:

score: 0
Extra Test Passed