QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#261370#3042. Hilbert's HotellmeowdnWA 40ms13624kbC++142.6kb2023-11-22 20:39:522023-11-22 20:39:54

Judging History

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

  • [2023-11-22 20:39:54]
  • 评测
  • 测评结果:WA
  • 用时:40ms
  • 内存:13624kb
  • [2023-11-22 20:39:52]
  • 提交

answer

//vanitas vanitatum et omnia vanitas
#include<bits/stdc++.h>
#define fi first
#define se second
#define eb emplace_back
#define mp make_pair
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef __int128 i128;
template<typename T,typename U>
T ceil(T x, U y) {return (x>0?(x+y-1)/y:x/y);}
template<typename T,typename U>
T floor(T x, U y) {return (x>0?x/y:(x-y+1)/y);}
template<class T,class S>
bool chmax(T &a,const S b) {return (a<b?a=b,1:0);}
template<class T,class S>
bool chmin(T &a,const S b) {return (a>b?a=b,1:0);}
int popcnt(int x) {return __builtin_popcount(x);}
int popcnt(ll x)  {return __builtin_popcountll(x);}
int topbit(int x) {return (x==0?-1:31-__builtin_clz(x));}
int topbit(ll x)  {return (x==0?-1:63-__builtin_clzll(x));}
int lowbit(int x) {return (x==0?-1:__builtin_ctz(x));}
int lowbit(ll x)  {return (x==0?-1:__builtin_ctzll(x));}

#define int long long
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vp;
typedef tuple<int,int,int> tiii;
int read() {
  int x=0,w=1; char c=getchar(); 
  while(!isdigit(c)) {if(c=='-') w=-1; c=getchar();}
  while(isdigit(c)) {x=x*10+(c-'0'); c=getchar();}
  return x*w;
}

const int N=3e5+5,mod=1e9+7;
int n,s[N],lst[N],m,cur,mul,add,pd,p[N],a[N],tk[N],tq;

int ksm(int x,int y,int r=1) {
  for(;y;y>>=1,x=x*x%mod) if(y&1) r=r*x%mod;
  return r;
}

signed main() {
  n=read(); mul=1;
  rep(i,1,n) {
    int opt=read();
    if(opt==1) {
      m++; lst[m]=cur; int k=read(); s[m]=s[m-1]+(tk[m]=k);
      if(!k) {
        ++pd, cur=m, mul=mul*2%mod, add=add*2%mod;
        a[m]=(mod+1-add)*ksm(mul,mod-2)%mod;
        p[m]=1-pd;
      } else {
        add+=k;
        a[m]=(mod-add)*ksm(mul,mod-2)%mod;
        p[m]=-pd;
      }
    } else if(opt==2) {
      int g=read(), x=read(); ++tq; 
      int sa=(a[g]*mul+add)%mod, sp=p[g]+pd;
      printf("%lld\n",(sa+(x-1)*ksm(2,sp))%mod);
    } else {
      int ans=0, k=read(); ++tq;
      for(int x=m;x;) {
        if(!tk[x]) {
          if(k&1) {ans=x; break;}
          else k/=2;
          x--;
        } else {
          int ss=s[x]-s[lst[x]];
          if(k+1>ss) k-=ss;
          else {
            int l=lst[x]+1, r=x;
            while(l<=r) {
              int mid=l+r>>1;
              if(s[x]-s[mid-1]>=k+1) ans=mid, l=mid+1;
              else r=mid-1; 
            }
            break;
          }
          x=lst[x];
        }
      }
      printf("%lld\n",ans);
    }
  }
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 10124kb

input:

10
3 0
1 3
2 1 2
1 0
3 10
2 2 5
1 5
1 0
3 5
2 3 3

output:

0
1
0
9
4
4

result:

ok 6 lines

Test #2:

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

input:

16
2 0 8
2 0 4
3 7
3 5
2 0 8
3 6
1 0
3 8
2 0 2
1 2
2 2 1
2 2 1
1 6
1 1
3 4
2 3 2

output:

7
3
0
0
7
0
0
2
0
0
3
2

result:

ok 12 lines

Test #3:

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

input:

11
2 0 8
3 9
1 5
2 0 10
2 0 5
1 0
3 9
2 2 7
2 2 3
3 0
1 0

output:

7
0
14
9
2
13
5
1

result:

ok 8 lines

Test #4:

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

input:

20
1 0
3 1
2 0 4
2 0 7
1 0
3 8
1 0
2 3 7
3 4
2 3 4
3 1
3 8
1 0
2 4 5
1 9
3 2
3 3
3 2
1 7
1 0

output:

1
6
12
0
13
1
7
3
0
9
5
5
5

result:

ok 13 lines

Test #5:

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

input:

11
1 0
2 0 4
2 0 9
1 1
1 9
1 4
2 0 8
2 4 3
2 1 3
1 2
2 3 6

output:

6
16
28
2
19
11

result:

ok 6 lines

Test #6:

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

input:

20
2 0 9
2 0 9
1 0
3 6
1 9
2 0 10
2 1 10
3 7
3 5
1 0
2 1 1
2 1 5
1 7
2 3 3
2 2 2
1 8
1 4
1 0
1 0
2 5 2

output:

8
8
0
27
28
2
2
20
36
12
9
20

result:

ok 12 lines

Test #7:

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

input:

15
2 0 4
3 4
1 0
2 1 7
3 10
1 0
1 0
2 1 1
2 1 2
2 2 5
1 0
2 2 10
1 0
2 1 6
1 0

output:

3
0
13
0
4
12
18
76
176

result:

ok 9 lines

Test #8:

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

input:

13
1 2
1 2
3 3
2 0 6
3 8
2 0 3
2 2 2
3 8
2 1 2
1 4
1 0
1 4
1 0

output:

1
9
0
6
1
0
3

result:

ok 7 lines

Test #9:

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

input:

11
3 4
2 0 9
3 9
1 0
3 5
1 0
2 0 8
2 0 9
2 2 3
3 6
2 0 9

output:

0
8
0
1
28
32
5
1
32

result:

ok 9 lines

Test #10:

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

input:

13
3 6
1 0
1 7
3 4
3 1
2 0 8
1 9
1 9
1 5
3 10
3 10
2 4 6
2 3 9

output:

0
2
2
21
4
4
10
22

result:

ok 8 lines

Test #11:

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

input:

17
3 10
3 0
2 0 7
3 3
2 0 9
1 0
2 0 7
2 0 10
2 0 6
2 1 4
1 0
1 0
3 7
2 1 2
3 3
1 9
3 5

output:

0
0
6
0
8
12
18
10
7
3
12
3
4

result:

ok 13 lines

Test #12:

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

input:

18
1 0
3 3
1 4
2 2 3
2 2 4
2 2 2
2 0 10
3 3
3 1
3 9
1 0
1 1
1 9
3 4
1 9
2 4 1
3 0
3 6

output:

1
2
3
1
22
2
2
1
5
18
6
6

result:

ok 12 lines

Test #13:

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

input:

990
3 613
3 983
3 529
2 0 4
2 0 8
3 352
3 136
2 0 1
2 0 6
3 144
3 936
1 7
3 102
2 0 3
2 0 4
1 0
2 0 10
3 381
3 200
2 2 4
1 6
3 251
1 9
2 4 5
1 3
2 3 6
2 1 4
3 65
2 2 6
2 2 4
3 934
2 3 6
2 3 3
2 2 10
2 1 2
2 5 3
3 618
3 996
3 335
3 268
2 3 6
1 5
1 5
2 4 7
1 6
1 5
3 347
3 646
1 3
1 6
2 8 1
3 845
1 7
3...

output:

0
0
0
3
7
0
0
0
5
0
0
0
9
10
32
2
0
7
2
4
17
24
2
29
25
0
17
14
37
20
2
0
0
2
0
17
19
0
2
14
2
2
2
17
3
109
4
195
30
28
54
24
24
24
8
0
3
368
24
17
24
1561
39
1369
24
28
875
103
28
219
20
74
234
28
26
28
28
379
742
28
56
26
1064
28
28
28
35
1288
426
18
28
1642
2
117
1049
819
44
19
26
44
28
24
3370
4...

result:

ok 652 lines

Test #14:

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

input:

942
1 0
3 671
3 788
1 4
3 146
2 0 9
2 2 3
3 130
3 343
3 783
1 10
3 36
1 9
2 1 7
1 0
3 85
2 4 3
2 5 3
2 5 9
1 0
2 0 9
3 913
2 1 8
2 2 4
3 164
1 6
2 5 7
1 6
3 628
1 3
2 1 6
1 7
1 0
3 545
3 319
3 551
3 672
3 464
3 680
3 670
2 11 3
2 6 7
2 4 8
3 535
1 9
3 394
2 9 2
1 0
2 7 6
1 10
1 0
2 1 2
1 0
2 2 4
2 3...

output:

1
0
0
20
2
0
1
1
0
36
5
4
5
17
156
6
152
88
0
32
1
151
11
11
11
5
5
5
6
5
70
100
11
11
25
102
1064
1872
1040
2774
220
19
669
413
27
19
20
4413
19
19
16
33
19
22
696
15
1403
19
19
130
28
197
1877
19
19
19
360
31
33
35
16
35
1703
855
423
35
2180
38
3
162
162
14182
4774
40
130406
40
3174
13
40
40
40
38...

result:

ok 607 lines

Test #15:

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

input:

904
3 946
3 64
3 559
3 380
1 4
1 0
3 555
1 7
1 9
3 319
2 4 3
1 2
1 0
3 104
1 2
1 4
1 9
2 3 5
2 9 9
2 7 2
2 7 2
1 7
1 1
2 1 1
3 180
3 687
1 2
2 11 1
3 785
1 10
1 5
2 1 4
3 758
3 275
3 182
2 12 2
2 6 4
2 14 5
3 718
3 356
1 4
2 5 2
1 1
2 13 3
2 16 1
1 5
1 6
2 6 1
3 573
2 14 1
1 3
2 19 2
3 211
2 8 4
3 2...

output:

0
0
0
0
2
2
2
0
45
8
14
14
59
6
0
2
0
88
2
6
2
16
47
4
2
0
46
12
0
57
6
16
1
0
56
14
85
87
27
2
58
39
6
6
2
22
6
89
6
1
0
42
280
29
618
30
2
487
1183
25
8
134
30
22
1070
30
30
22
30
255
29
30
820
22
313
1481
20
43
43
40
4252
39
30
43
6498
1218
43
46
15316
3476
2772
26
70
43
836
46
40
43
46
14164
39
...

result:

ok 609 lines

Test #16:

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

input:

935
1 4
2 0 2
1 3
2 1 3
3 61
2 2 3
1 5
1 3
2 0 9
2 1 1
2 4 2
2 2 3
2 1 3
3 430
1 2
3 517
1 8
1 7
1 0
1 2
2 3 1
3 744
2 0 7
3 413
2 5 1
1 0
2 6 8
1 6
3 61
3 718
1 0
3 387
2 9 1
2 11 5
3 987
2 9 2
3 723
2 0 5
3 362
2 2 1
3 887
3 311
1 1
1 4
1 7
3 279
3 374
1 2
3 787
3 374
3 803
3 212
1 10
1 1
1 2
1 0
...

output:

5
5
0
2
23
11
1
10
13
0
0
42
0
78
8
32
60
10
0
12
12
8
12
16
12
308
10
220
12
12
12
10
12
8
12
10
166
98
654
206
20
286
8
10
7
102
74
24
24
20
587
94
24
1137
24
13
1
24
34
6
31
35
17
24
8
24
137
31
38
31
23
93
121
31
31
38
24
2247
24
24
39
7
31
1929
161
71
22
227
185
177
101
57
12
931
31
31
31
26
46...

result:

ok 613 lines

Test #17:

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

input:

999
3 86
3 146
3 588
3 62
3 143
3 85
2 0 5
2 0 4
3 678
1 9
3 500
1 2
1 0
3 835
1 8
1 3
1 10
2 2 1
1 5
3 154
1 8
2 6 6
3 463
3 782
2 4 3
1 7
3 995
2 7 4
1 3
3 546
1 0
1 0
2 9 3
2 0 5
3 356
3 361
2 1 5
3 948
2 6 9
2 9 1
1 8
3 445
2 2 1
1 8
3 41
2 9 2
2 13 1
3 98
2 0 4
3 184
3 44
1 6
3 413
3 602
1 7
2 ...

output:

0
0
0
0
0
0
4
3
0
0
3
21
0
18
3
0
28
0
18
0
20
296
3
12
224
3
124
12
12
184
12
32
8
11
304
4
9
12
3
161
18
0
22
25
12
1
244
11
39
232
12
33
0
6
682
11
482
14
12
21
273
83
17
17
21
21
12
15
21
12
5
170
860
36
36
21
64
37
2744
156
26
21
264
32
36
2872
36
36
37
16
37
2
2198
37
21
317
369
37
41
21
21
30...

result:

ok 656 lines

Test #18:

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

input:

951
3 497
2 0 10
2 0 9
3 250
1 6
3 887
1 1
2 0 8
2 1 4
3 711
2 2 1
3 194
3 314
2 0 3
2 1 6
2 2 1
1 8
3 355
1 6
3 650
2 0 1
1 9
2 3 7
1 10
3 775
2 1 5
3 463
3 476
2 1 6
2 2 1
1 8
3 797
2 6 9
2 1 4
2 3 5
1 3
1 0
1 6
3 783
2 1 5
3 908
1 0
1 3
1 1
2 11 5
2 13 1
2 10 5
1 5
1 4
1 7
1 1
2 0 4
1 0
1 7
3 465...

output:

0
9
8
0
0
14
4
0
0
0
0
9
6
0
0
0
21
21
0
38
0
0
39
33
0
16
45
37
9
104
0
13
0
12
249
1
18
18
560
60
44
11
643
18
70
302
9
22
11
539
923
1115
155
7
29
1501
1565
205
9
29
29
163
347
29
22
102
17
1074
85
29
29
633
25
777
1
634
18
39
29
410
1522
47
489
39
362
1582
47
2256
47
750
39
62
39
34
2265
59
358
...

result:

ok 611 lines

Test #19:

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

input:

913
3 715
2 0 5
3 302
1 2
2 0 1
2 1 2
1 3
1 6
2 1 2
1 1
2 1 1
2 2 1
3 14
3 729
2 2 2
2 2 3
2 1 1
3 732
3 516
1 9
1 7
2 6 1
2 3 5
3 255
3 303
3 27
3 747
2 1 1
1 3
1 7
2 0 4
3 2
2 6 2
3 178
1 9
1 0
1 7
1 3
1 1
1 7
3 364
1 0
2 0 8
3 513
1 9
1 4
3 902
1 4
2 13 1
3 801
2 2 1
3 329
1 10
3 958
3 320
3 984
...

output:

0
4
0
2
1
10
10
7
0
0
8
9
10
0
0
0
21
0
0
1
0
26
41
8
11
0
0
252
15
15
31
0
221
0
15
15
15
43
15
0
83
9
15
23
23
23
23
824
239
15
79
95
925
40
915
936
23
850
56
19
21
37
37
21
54
37
2197
13
597
209
37
103
195
23
23
140
35
668
500
1708
91
14
196
2550
37
686
53
39
31
489
53
349
401
23
285
470
46
56
91...

result:

ok 602 lines

Test #20:

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

input:

977
3 637
3 620
3 388
1 0
2 0 7
2 1 1
3 989
3 446
1 0
3 987
3 20
1 6
3 241
1 7
1 6
1 2
2 3 4
3 400
2 5 2
1 6
1 9
3 758
3 657
2 0 10
3 772
3 601
2 5 1
2 7 3
3 327
3 51
2 2 3
3 314
3 609
1 3
1 8
2 7 3
1 0
1 0
3 782
3 667
3 953
3 292
1 4
1 5
1 8
1 4
3 431
1 3
1 10
3 464
1 7
1 7
1 0
1 4
1 5
2 3 5
3 713
...

output:

0
0
0
12
1
1
0
2
0
2
18
2
3
1
2
72
0
2
17
11
2
2
41
1
2
22
11
12
12
1
11
11
465
2
11
11
1348
26
31
448
4754
31
31
1493
853
269
1365
28
28
31
31
719
3168
31
21
258
10
986
98
4724
21
2744
31
717
3973
28
649
31
31
31
1028
47
78
31
205
42
28
26
81
77
51
211
3551
1439
26
8
51
127
6
51
51
51
51
187
28
51
...

result:

ok 626 lines

Test #21:

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

input:

940
1 6
3 869
1 3
3 579
2 0 4
2 1 5
3 443
3 460
1 4
3 715
3 42
2 0 5
1 5
2 0 2
1 7
3 260
1 9
2 3 3
3 502
1 8
3 420
1 4
3 676
3 54
1 0
1 6
2 2 3
2 6 8
2 4 4
3 192
3 470
2 1 6
3 663
2 6 6
2 2 1
2 8 1
3 205
3 193
3 840
1 3
2 0 1
3 616
2 0 4
1 0
3 3
2 8 2
3 440
2 7 4
3 320
3 683
2 5 7
1 3
1 10
2 5 6
3 8...

output:

0
0
12
7
0
0
0
0
17
19
0
23
0
0
0
0
84
44
68
0
0
96
9
40
80
6
9
9
0
101
9
107
12
22
9
46
9
12
126
135
12
58
14
15
15
12
61
54
18
18
18
18
18
17
18
44
17
19
18
18
28
12
17
17
18
9
17
273
18
18
388
18
47
18
17
18
8
15
90
159
18
34
139
53
18
15
34
161
34
100
76
74
2708
18
857
34
34
35
34
417
7
2593
34
...

result:

ok 644 lines

Test #22:

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

input:

988
2 0 1
3 374
1 0
3 649
2 1 2
1 2
2 0 8
3 543
3 318
1 7
3 228
2 0 5
3 114
2 2 2
3 661
2 0 3
2 1 1
2 3 5
3 275
2 0 8
2 3 7
2 0 10
3 384
3 250
2 0 8
2 3 7
2 2 1
1 0
1 9
1 2
3 536
1 0
1 6
3 777
1 10
2 3 7
2 9 6
3 85
2 1 8
1 10
1 0
2 10 5
1 6
3 155
1 8
3 467
2 3 7
1 7
3 908
2 14 4
1 1
3 176
2 12 4
2 2...

output:

0
0
1
3
16
1
0
1
17
1
8
0
13
10
4
0
23
6
27
1
1
23
6
7
4
7
62
5
7
134
8
11
11
158
11
3
7
19
174
5
158
11
1
28
212
184
7
99
603
27
27
161
28
16
367
36
750
78
13
17
1086
36
1262
28
518
1566
28
30
28
1892
27
36
1288
28
28
2028
25
68
48
1384
28
36
216
36
54
1426
34
36
226
738
0
19
13
28
32
1088
15
234
3...

result:

ok 687 lines

Test #23:

score: 0
Accepted
time: 31ms
memory: 13216kb

input:

285800
1 589
2 1 115
2 1 226
2 1 514
2 1 456
3 629709122
1 619
2 2 192
3 459147753
1 38
2 2 576
2 3 8
3 201981823
3 524189144
2 3 32
1 56
2 4 20
3 214735859
1 890
2 5 636
3 478695264
3 460825804
2 5 103
3 952035202
2 0 286
1 525
1 288
1 957
2 0 618
3 735607495
2 1 93
2 1 286
1 985
2 9 663
1 683
2 2 ...

output:

114
225
513
455
0
191
0
613
7
0
0
31
19
0
635
0
0
102
0
2477
4579
0
3465
3658
662
5004
5531
0
0
0
6085
6160
6201
2926
0
0
0
4574
2946
0
17
12920
16648
11235
17
0
7809
17
17
0
13273
0
17
17
0
0
10365
1695
0
0
0
40360
0
50264
26
26
46388
279
51921
26
35101
0
17
26
3285
26
39483
26
17
26
2946
1358
26
1...

result:

ok 190990 lines

Test #24:

score: 0
Accepted
time: 31ms
memory: 11336kb

input:

291729
1 894
1 890
3 802126177
3 272286217
1 0
2 1 374
3 891152646
1 820
2 2 147
1 310
3 46206280
2 4 808
3 18706394
2 1 331
3 664920704
2 1 654
2 0 748
3 192123924
3 708982947
3 220679626
3 704888628
1 160
3 964332875
3 169548294
3 662085712
3 515358639
3 958291113
3 383486479
2 4 124
1 392
1 239
3...

output:

0
0
2526
0
1112
0
1117
0
3570
0
4216
6192
0
3
0
0
3
0
0
3
3
3
593
3
0
0
5
1897
0
0
0
0
0
3
3
2150
6351
1428
3
5329
3
3
3489
0
3
8227
0
2160
0
5477
0
0
3
3
82
20
20
3
20
0
20
4751
238
13901
12751
20
20
12981
20
10553
3
8989
0
1960
0
6055
20
168
20
16079
20
0
20
20
0
20
5514
20
7175
20
3794
0
25384
22...

result:

ok 194496 lines

Test #25:

score: 0
Accepted
time: 31ms
memory: 13160kb

input:

284878
1 658
1 878
1 399
2 0 139
1 36
2 2 769
1 823
2 3 335
3 383102579
1 735
2 2 460
3 907616047
3 165176802
2 1 219
3 425702053
3 428981593
1 721
2 0 39
3 727162062
1 477
1 311
2 2 562
3 451950835
3 65057699
1 710
1 712
2 6 339
3 7344432
2 2 628
1 75
1 978
3 19967679
1 97
1 402
3 160663473
1 702
3...

output:

2073
1203
1193
0
2452
0
0
3089
0
0
4288
0
4063
0
0
3269
0
5551
0
0
0
2502
0
6753
6868
5339
0
3156
0
4021
833
1931
0
1400
92
2825
8558
85
0
0
0
0
0
0
5908
0
0
0
0
10790
0
8549
2276
3721
0
0
0
7722
0
0
7467
0
12167
0
9930
32
32
26552
0
32
0
32
0
28113
32
9559
0
1385
2315
32
0
32
0
9841
22878
0
0
2384
...

result:

ok 189957 lines

Test #26:

score: 0
Accepted
time: 40ms
memory: 13624kb

input:

294009
3 967557698
1 914
1 302
3 745869808
3 990025222
1 998
1 310
3 173316754
2 2 134
2 1 212
2 0 3
3 974856036
2 1 306
1 176
1 252
3 469723561
3 809790361
3 131203832
2 5 114
2 3 329
2 3 627
3 609236246
2 0 80
1 788
1 961
3 223398965
1 899
2 2 45
1 466
3 857489318
2 6 103
1 686
3 717426508
3 18954...

output:

0
0
0
0
1441
1821
2526
0
1915
0
0
0
365
1066
1364
0
3031
0
4428
0
3216
0
0
0
398
0
6193
2152
0
0
2796
1130
22440
22752
17
14
17
17
20
52796
17
20
26469
17
85466
4846
25
265216
13200
25
25
23
37377
4096
31
26510
3605
1285727
107572
31
848500
566772
773492
31
31
34429
31
75261
23
31
31
31
31
31
917779...

result:

ok 196252 lines

Test #27:

score: 0
Accepted
time: 35ms
memory: 8652kb

input:

282562
2 0 74
3 17540587
3 68688373
2 0 562
3 593200593
1 850
3 850964180
2 1 606
1 849
2 0 994
1 793
1 8
1 19
2 3 285
1 936
1 945
3 897195209
3 689162617
3 432243973
2 6 597
3 513148040
2 7 575
2 6 501
2 4 5
1 481
2 0 437
2 7 835
3 782722001
1 974
2 1 271
1 109
1 0
2 3 151
1 250
2 12 5
3 569019713
...

output:

73
0
0
561
0
0
605
2692
311
0
0
0
1541
0
574
1445
1904
5317
1315
0
5275
7244
4
11
11
1436
11
11
14588
740
0
11
0
10972
1766
0
0
3085
161
10732
9200
11
10107
11
11
14370
3175
14801
3459
0
17134
3199
0
15506
12506
0
6631
4229
11
20505
0
11
11
0
11
12943
8697
11
17509
11
11
7739
0
11
11
37
18529
37
0
2...

result:

ok 188785 lines

Test #28:

score: 0
Accepted
time: 28ms
memory: 13460kb

input:

293374
1 225
3 447206486
2 0 878
1 827
1 194
3 390633943
3 360374143
3 637018590
3 951750234
1 0
2 3 71
3 526531042
1 66
1 835
2 1 225
1 0
3 531166748
3 609646428
2 6 825
3 281460658
2 4 438
3 722590971
3 436988302
3 107135791
1 449
2 4 953
1 404
1 733
1 380
2 0 436
1 837
3 747811327
2 9 264
3 61480...

output:

0
1102
0
0
0
0
140
0
3391
4
4
1648
0
3552
7
0
7
6061
10492
4
2213
0
4527
0
245
0
343
7
117
15
1511
15
0
4004
7
4
9
3525
21453
15
15
12821
17064
7377
15
1689
4
4
3852
7
2118
4
9620
9033
922
15
3760
15
30716
15
7
7
7
22041
15
15
15
11411
15
15
15
27735
30127
15049
51
15
16227
85699
12952
35104
51
1912...

result:

ok 195658 lines

Test #29:

score: 0
Accepted
time: 39ms
memory: 10112kb

input:

287143
3 402401437
2 0 394
1 93
3 644955565
1 606
2 0 840
3 697316701
1 657
3 482937747
3 844029157
2 1 54
2 0 669
3 162399854
2 2 461
2 1 88
1 62
1 490
2 3 359
1 320
1 348
2 3 396
1 391
1 486
2 0 984
3 126661122
2 8 116
1 774
2 4 24
3 366371654
3 695192494
1 86
3 885892130
3 860516461
2 11 64
3 794...

output:

0
393
0
1538
0
0
0
1316
2024
0
1117
1350
910
1615
4436
0
601
2832
0
0
0
0
63
0
0
2037
0
0
1963
0
0
0
0
5519
0
0
1531
0
0
5606
67
0
1731
0
2161
0
209
0
0
23
0
0
23
9671
0
17149
2963
180
27
27
27
27
27
26210
14411
29911
27
27
27
4290
8483
39631
3087
23
27
23
48604
23
8258
4853
4436
19235
27
28691
27
4...

result:

ok 191311 lines

Test #30:

score: 0
Accepted
time: 35ms
memory: 10636kb

input:

282111
3 312193607
2 0 560
1 664
3 4141348
1 107
2 2 89
1 196
3 224802799
1 0
3 513505207
3 258517554
1 722
2 2 4
2 4 17
3 333760602
2 0 701
2 3 103
2 3 71
1 48
1 44
3 342943369
2 7 19
2 7 35
3 567363618
3 536126078
1 85
2 5 170
1 810
3 453599856
3 701607165
2 5 49
3 498442155
1 374
2 8 60
2 1 341
1...

output:

0
559
0
88
0
4
0
1120
755
0
4056
926
862
4
18
34
0
0
346
4
0
1035
0
1243
3369
39
0
4
0
970
2424
0
4
2354
4
3211
5151
4
4
3587
21
20
7086
19966
21
21802
21
5017
15057
1816
3397
21
20
4
21
21
21
2729
21
2933
0
21
20
21
10428
21
3295
0
4
21
21
25631
21111
26215
996
10063
9219
21
21
21
21
21
20
4
0
1514...

result:

ok 188398 lines

Test #31:

score: 0
Accepted
time: 27ms
memory: 11340kb

input:

292901
1 701
3 91197427
2 1 626
3 434122436
1 175
1 22
1 369
2 3 12
2 3 22
2 2 58
1 566
3 417019594
2 3 3
1 110
3 213369210
1 921
1 483
1 597
2 4 169
1 415
1 847
3 297474705
1 301
1 2
1 762
2 14 724
2 12 187
2 8 20
2 7 549
2 10 237
3 503174622
2 2 14
3 51110086
1 864
3 433753526
2 15 237
1 650
1 249...

output:

0
625
0
380
390
448
0
937
0
2845
0
723
950
2943
3955
2148
0
5408
0
0
236
0
0
3206
642
0
0
0
2682
0
0
9010
0
2282
0
0
0
21466
25
25
6562
28
25
27
0
98931
0
54836
6658
58908
8500
28
73978
6
28
71625
28
8205
28
28
14171
93123
36939
6101
839
57203
27
5084
28
28
27657
30065
44
36394
28
2742
25
44
5284
44...

result:

ok 195292 lines

Test #32:

score: 0
Accepted
time: 35ms
memory: 10388kb

input:

285160
2 0 430
2 0 118
2 0 314
3 519690597
1 0
2 1 398
3 488819169
2 1 167
1 230
3 987277461
3 536897357
2 1 256
1 222
1 356
2 0 142
3 51827303
1 0
3 727040389
2 1 682
3 805524180
1 582
3 151359420
1 594
2 2 121
2 5 151
3 973152736
3 490971920
2 6 304
3 637107033
3 118697284
3 411400129
1 772
3 7126...

output:

429
117
313
0
795
1
333
1
1
741
1090
1
5
4342
0
1
2572
1477
0
0
897
5
0
5
0
1
5044
2848
565
1471
2200
3218
1988
5
1
5
5
8241
4351
6409
3989
5591
3792
5
2656
1
1
1
5546
5
0
4195
2962
9120
6462
5
5099
2980
1373
4367
3113
5
738
2103
7869
750
0
2342
2297
5
0
5
5
5984
1677
0
22
8939
1
9149
11004
10207
1
...

result:

ok 189971 lines

Test #33:

score: -100
Wrong Answer
time: 36ms
memory: 10336kb

input:

300000
2 0 206645902
3 636812873
1 997512702
2 0 239322423
2 0 504136008
2 1 804093075
3 371921677
2 0 328983963
1 283098207
3 348255721
2 0 11511005
2 0 520395076
3 984652715
1 705801389
2 0 739168623
1 92371913
3 808770816
3 281469617
2 2 129064647
1 664544935
2 2 255494310
1 65295784
1 666122355
...

output:

206645901
0
236835117
501648702
804093074
1
326496657
1
292121906
801005977
1
725580906
2
3
927237948
718212539
649988257
9
8
10
267718588
10
10
693418111
14
918955204
15
776439118
513296405
16
16
573290907
19
280956541
458991884
129863464
22
22
21
216009995
856387310
114184303
228372748
663503951
8...

result:

wrong answer 69th lines differ - expected: '275762727', found: '-724237280'