QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#371718#4891. 树上的孤独zsq147258369100 ✓1852ms267392kbC++172.2kb2024-03-30 15:10:422024-03-30 15:10:43

Judging History

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

  • [2024-03-30 15:10:43]
  • 评测
  • 测评结果:100
  • 用时:1852ms
  • 内存:267392kb
  • [2024-03-30 15:10:42]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;const int N=5e5+50,Q=2e6,M=21,inf=1e9+7,T=1e7;int n,m,q,c[M],V[N],rc[M];vector<int>s[M],g[N];struct edge{int u,v,nxt;}e[N];int H[N],cnt,dp[M];void O(){int u,v;cin>>u>>v;e[++cnt]=(edge){u,v,H[u]};H[u]=cnt;e[++cnt]=(edge){v,u,H[v]};H[v]=cnt;}void A(){int u,v;cin>>u>>v;g[u].push_back(v);g[v].push_back(u);}void init(int x,int fa){s[x].push_back(x);dp[x]=dp[fa]+1;for(auto v:g[x])if(v!=fa){init(v,x);for(auto t:s[v])s[x].push_back(t);}}vector<int>L[N];int cc[N],ty[Q],Y[Q],U[Q],W[Q],R[Q],siz[N],son[N],d[N],rv[N];void dfs(int x,int f){siz[x]=1;d[x]=d[f]+1;for(int i=H[x];i;i=e[i].nxt)if(e[i].v!=f){int v=e[i].v;dfs(v,x);siz[x]+=siz[v];if(siz[v]>siz[son[x]])son[x]=v;}}vector<int>p[M];int D[M][N],B[M][N];int sum[T],tot,tl[T],tr[T],ro[N];
#define mid ((l+r)>>1)
void I(int&x,int l,int r,int d,int w){++tot;sum[tot]=sum[x]+w;tl[tot]=tl[x];tr[tot]=tr[x];x=tot;if(l==r)return;if(d<=mid)I(tl[x],l,mid,d,w);else I(tr[x],mid+1,r,d,w);}int F(int x,int l,int r,int L,int R){if(L<=l&&R>=r)return sum[x];if(!x)return 0;int ans=0;if(L<=mid)ans+=F(tl[x],l,mid,L,R);if(R>mid)ans+=F(tr[x],mid+1,r,L,R);return ans;}void up(int E,int w,int d,int x){if(!B[E][w]){B[E][w]=1,D[E][w]=d,I(ro[x],1,m,d,1),p[E].push_back(w);}else if(D[E][w]>d)I(ro[x],1,m,D[E][w],-1),I(ro[x],1,m,d,1),D[E][w]=d;}void G(int u,int v,int x){for(auto w:p[v])up(u,w,D[v][w],x),B[v][w]=0;}void S(int x,int fa,int E){if(son[x])S(son[x],x,E),ro[x]=ro[son[x]];up(E,V[x],d[x],x);for(int i=H[x];i;i=e[i].nxt)if(e[i].v!=fa&&e[i].v!=son[x]){int v=e[i].v;p[E+1].clear();S(v,x,E+1);G(E,E+1,x);}for(auto&t:L[x])t=(B[E][t]?D[E][t]:inf);}main(){cin>>n>>m>>q;for(int i=1;i<n;i++)A();for(int i=1;i<m;i++)O();for(int i=1;i<=n;i++)cin>>c[i],rc[i]=c[i];for(int i=1;i<=m;i++)cin>>V[i];init(1,0);for(int i=1;i<=q;i++){cin>>ty[i];if(ty[i]==1){cin>>W[i]>>R[i]>>Y[i]>>U[i];for(auto x:s[W[i]])L[R[i]].push_back(c[x]);}else cin>>W[i]>>R[i],c[W[i]]=R[i];}dfs(1,1);S(1,1,1);for(int i=1;i<=n;i++)c[i]=rc[i];for(int i=1,las=0,u,v;i<=q;i++){if(ty[i]==1){Y[i]^=las;U[i]^=las;u=R[i],v=W[i];las=F(ro[u],1,m,d[u],min(m,d[u]+U[i]));for(auto x:s[v]){if(dp[x]-dp[v]<=Y[i]&&rv[c[x]]!=i)rv[c[x]]=i,las+=(L[u][cc[u]]>d[u]+U[i]);++cc[u];}cout<<las<<'\n';}else c[W[i]]=R[i];}}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 3ms
memory: 30784kb

input:

20 2000 2000
8 15
8 13
14 8
14 7
12 14
12 1
9 13
9 4
5 9
5 10
2 5
2 19
6 19
6 16
11 7
11 20
18 2
18 17
3 6
1395 1783
1395 1735
1735 457
457 739
739 438
438 101
101 441
441 1879
1879 1238
1238 501
501 1732
1732 1910
1910 2000
2000 834
834 917
917 111
111 780
780 1966
1966 1604
1604 623
623 1748
1748 ...

output:

105
93
2
44
19
54
192
25
69
21
21
200
78
88
137
33
68
68
54
35
24
8
23
78
59
100
27
200
40
74
97
21
87
36
197
76
28
49
11
20
55
60
24
5
109
158
23
21
15
102
36
108
26
78
171
82
32
147
145
9
136
31
109
142
119
68
34
64
18
40
56
48
54
14
35
154
111
130
144
200
21
80
84
37
73
24
28
37
160
51
62
51
95
2...

result:

ok 1481 numbers

Test #2:

score: 0
Accepted
time: 7ms
memory: 29400kb

input:

20 2000 2000
7 9
7 4
20 4
20 15
19 7
19 3
11 9
11 8
5 19
5 1
13 19
13 10
12 5
6 3
17 8
17 14
2 3
2 18
16 5
304 1166
304 1254
1254 1939
1939 430
430 1573
1573 1917
1917 934
934 226
226 1722
1722 453
453 562
562 151
151 1985
1985 1689
1689 1492
1492 108
108 948
948 753
753 92
92 1347
1347 1940
1940 10...

output:

34
197
20
99
87
35
26
19
2
36
87
19
66
199
5
156
19
35
129
62
12
199
96
19
52
4
38
198
19
200
36
60
47
64
44
172
15
48
20
166
147
53
23
46
140
48
56
77
134
39
49
200
67
19
19
40
2
19
158
24
21
79
91
45
12
126
183
20
122
29
21
28
27
65
28
58
141
25
20
172
20
3
179
7
46
141
57
57
43
150
2
86
25
8
72
2...

result:

ok 1495 numbers

Subtask #2:

score: 20
Accepted

Test #3:

score: 20
Accepted
time: 1048ms
memory: 182928kb

input:

20 200000 500000
8 18
8 4
2 4
2 14
13 4
13 16
6 4
6 3
1 4
1 17
15 6
15 19
7 17
7 11
5 14
5 10
20 7
12 15
9 8
165302 77239
165302 198189
165302 180850
165302 192738
165302 173589
165302 194087
165302 191990
165302 167370
165302 101092
165302 92553
165302 163654
165302 122381
165302 152105
165302 1919...

output:

2
17595
3898
3423
16
518
5138
11355
21
7340
21
18327
15797
6638
514
1184
6110
1884
6241
662
16738
13230
1597
5446
6074
2387
6265
2
21
282
3511
1806
1236
1038
17804
4657
5536
4633
4547
21
244
2703
2
4610
8571
4037
21
13498
5648
2054
3489
4869
5828
802
2072
1482
13232
2593
938
16769
2
17623
353
5
21
7...

result:

ok 500000 numbers

Test #4:

score: 0
Accepted
time: 1043ms
memory: 189168kb

input:

20 200000 500000
11 2
11 1
17 1
17 6
10 2
10 16
20 6
20 15
12 1
12 4
9 16
9 3
7 1
13 15
8 15
8 5
18 7
18 14
19 12
146231 199607
146231 196481
196481 194263
194263 192044
192044 169873
169873 141903
141903 129271
129271 176167
176167 170198
170198 173775
173775 174130
174130 184691
184691 198900
1989...

output:

933
12179
2009
2889
5129
7229
2884
5588
1070
21
2789
2194
654
2643
7840
3203
3946
105
1626
4635
775
2
14
6001
18249
18326
2
1386
3505
11361
1254
4501
5630
21
12011
1392
2902
5252
7857
4
1038
1796
3342
129
19959
18597
1924
116
104
1603
3593
4365
3967
921
1007
2344
4728
3051
2048
4607
4563
1648
8059
3...

result:

ok 500000 numbers

Test #5:

score: 0
Accepted
time: 1011ms
memory: 189288kb

input:

20 200000 500000
11 19
11 12
6 12
6 8
20 19
20 7
1 6
1 2
9 11
9 10
15 6
15 17
3 7
3 14
13 19
4 13
4 18
5 6
5 16
164001 91176
164001 174000
174000 170154
170154 69790
69790 174420
174420 193462
193462 149823
149823 188081
188081 127489
127489 191901
191901 194376
194376 197936
197936 185448
185448 19...

output:

5329
19807
5406
4355
2
1453
3216
21
2758
2561
387
8122
6615
4577
6108
2
2224
586
2950
19824
3119
6437
4852
5552
17244
7466
5462
2909
9992
19918
6653
19811
448
1026
1467
424
21
3056
1866
4262
9943
6499
3180
3688
6479
5096
6369
21
232
1765
2369
1789
1942
1141
3690
8680
7346
5265
21
16599
701
4354
1413...

result:

ok 500000 numbers

Test #6:

score: 0
Accepted
time: 1083ms
memory: 200496kb

input:

20 200000 500000
17 5
17 11
18 5
18 14
1 17
1 3
16 18
16 13
7 16
7 15
9 15
9 4
12 11
12 2
20 14
20 19
8 9
8 10
6 17
166750 113956
166750 160259
160259 143147
143147 172478
172478 173006
173006 89817
89817 196218
196218 191942
191942 193748
193748 177077
177077 157435
157435 125058
125058 164374
1643...

output:

2490
7164
1575
19999
2452
1702
26
21
5118
19981
10942
21
21
19266
1523
13
21
6341
21
1040
581
1643
7021
16863
7376
1626
1211
1982
21
15029
10542
14571
135
21
1001
21
1390
4982
2928
1539
5422
1095
2923
4872
1377
19997
14571
7196
4640
1988
1707
5216
5742
17354
12204
1941
17445
516
21
13
14682
19992
21...

result:

ok 500000 numbers

Subtask #3:

score: 30
Accepted

Test #7:

score: 30
Accepted
time: 211ms
memory: 91828kb

input:

20 100000 100000
16 12
16 20
6 12
6 18
2 16
2 8
5 20
5 13
3 6
3 11
19 11
19 17
9 12
9 15
4 15
4 7
10 5
14 15
14 1
85812 94626
85812 91172
91172 93788
93788 96567
96567 75524
75524 23275
23275 98340
98340 81608
81608 91480
91480 75108
75108 56605
56605 93317
93317 41617
41617 77160
77160 727
727 7559...

output:

2568
612
8337
8985
3561
9182
649
301
2478
7307
2682
1175
1401
1268
8228
4407
109
2696
640
4478
3165
9184
21
8980
2092
9950
8009
9944
21
5038
87
2038
1881
19
1292
2183
336
1101
9386
3477
7723
1958
2741
1256
2331
715
21
545
21
448
699
2332
447
18
38
1424
2321
693
2459
21
2320
714
9999
8
196
1366
8933
...

result:

ok 74842 numbers

Test #8:

score: 0
Accepted
time: 228ms
memory: 93620kb

input:

20 100000 100000
6 12
6 15
20 12
20 5
9 15
9 14
2 20
2 19
7 5
7 4
3 20
3 16
10 7
10 8
18 20
18 1
13 4
13 11
17 13
76027 68976
76027 57693
57693 93102
93102 28171
28171 85749
85749 99702
99702 83297
83297 72320
72320 89998
89998 69676
69676 84244
84244 44418
44418 78575
78575 4284
4284 99851
99851 90...

output:

1821
2139
1444
3155
8443
9995
2539
27
64
3274
2129
2
259
2719
152
3900
6031
5006
6290
879
1083
6041
496
6004
670
6
1451
1405
7249
977
9500
402
1104
1444
2795
2267
1171
1971
2886
5045
3
2699
765
3885
241
21
2683
1746
1756
7401
1111
4371
1107
1025
1369
1455
1420
2128
2165
6077
2793
1825
1263
2042
136
...

result:

ok 74861 numbers

Test #9:

score: 0
Accepted
time: 211ms
memory: 92728kb

input:

20 100000 100000
16 17
16 12
15 16
15 8
1 12
1 9
2 15
2 13
7 12
7 5
11 2
11 19
3 8
3 6
4 15
10 17
10 18
14 13
14 20
67546 88879
67546 89198
89198 92647
92647 60049
60049 72475
72475 67403
67403 26140
26140 9738
9738 85753
85753 31691
31691 30604
30604 84416
84416 92592
92592 96710
96710 84006
84006 ...

output:

3320
1811
2176
1515
9571
9829
2737
1223
1728
9815
9933
897
151
272
300
6209
7663
673
1113
918
2190
1241
1106
9988
4
7359
2882
2299
3278
3088
503
3767
1274
2
2160
4738
4304
184
75
2238
3879
192
9987
2744
1320
4089
2428
2759
740
2689
9306
85
3841
1510
3091
3
9327
3677
3221
4692
9315
7211
1780
9997
170...

result:

ok 74827 numbers

Test #10:

score: 0
Accepted
time: 205ms
memory: 90588kb

input:

20 100000 100000
2 3
2 6
17 2
17 10
5 2
5 9
20 10
20 18
7 2
7 16
13 2
13 8
4 10
4 14
11 17
11 15
19 10
19 12
1 11
85514 99510
85514 84831
85514 68620
85514 48208
85514 42479
85514 71645
85514 80596
85514 88493
85514 99514
85514 31378
85514 80504
85514 81861
85514 94839
85514 69330
85514 40591
85514 ...

output:

2
1716
3641
9997
3794
1209
3165
2597
1563
8595
463
4162
893
3028
435
8705
6861
1923
2814
2796
20
2363
1933
1893
762
673
13
7862
2839
2008
2985
2779
9993
2480
3
3712
9951
113
1062
9981
2059
697
3
109
2045
7767
861
149
70
9999
928
21
1017
2082
111
3375
242
1095
3325
880
3574
538
1954
20
376
1434
3507
...

result:

ok 74851 numbers

Test #11:

score: 0
Accepted
time: 216ms
memory: 92300kb

input:

20 100000 100000
12 10
12 5
17 5
14 10
14 8
9 8
9 13
16 12
16 19
6 8
6 3
18 19
18 15
1 12
1 7
20 19
20 4
2 12
11 4
34733 89384
34733 80376
80376 95740
95740 97840
97840 69394
69394 38211
38211 59175
59175 97280
97280 76697
76697 84307
84307 75221
75221 94161
94161 57166
57166 84005
84005 75107
75107...

output:

2486
7650
3313
2
7109
665
5733
1639
3748
5026
3376
3356
4964
9976
4326
982
2015
90
250
1631
3294
625
6789
7678
10000
653
3152
3312
3102
21
7581
2202
230
21
133
9852
3458
21
1652
5963
8692
2
121
3913
1395
3458
7411
3857
1934
355
3
3083
3213
9957
3132
281
8830
1462
6288
2980
1317
1648
897
1353
3303
19...

result:

ok 74832 numbers

Test #12:

score: 0
Accepted
time: 209ms
memory: 90456kb

input:

20 100000 100000
6 8
6 5
9 5
9 11
16 5
16 10
13 8
13 18
20 11
20 4
1 8
1 15
12 5
12 14
7 11
3 13
3 17
19 15
2 10
95202 70596
95202 63084
63084 80990
80990 97264
97264 75236
75236 76413
76413 21787
21787 79077
79077 23111
23111 87359
87359 12982
12982 71974
71974 94809
94809 78084
78084 89131
89131 9...

output:

3795
833
1450
8881
944
1103
4920
6523
2458
3126
642
4493
2278
300
3728
1304
155
474
99
6044
1871
2030
1058
2494
1320
1114
9563
853
1303
3571
377
5761
4259
1225
1700
705
24
1825
3684
2056
2800
9144
3778
1773
61
13
6935
44
9555
5851
2059
1639
3055
1632
2845
9999
9955
1577
610
587
3685
3517
865
66
1521...

result:

ok 74853 numbers

Subtask #4:

score: 10
Accepted

Test #13:

score: 10
Accepted
time: 821ms
memory: 158828kb

input:

1 200000 500000
189127 137023
189127 199761
199761 160701
160701 130639
130639 190908
190908 176819
176819 193363
193363 188021
188021 182446
182446 186028
186028 198828
198828 190792
190792 155378
155378 189428
189428 177276
177276 146159
146159 175923
175923 188073
188073 182206
182206 131072
1310...

output:

3782
1773
771
7328
18160
19394
1952
2
5498
2
2859
3368
7393
5131
5706
2
6001
19866
2
5123
2
12549
1497
4837
7770
16333
18175
5926
17983
19707
3821
17709
17094
4226
3822
576
5637
3660
4987
15686
2
18774
29
5068
16606
2276
16601
4544
598
845
19976
7054
882
164
2744
1683
6747
5091
1632
5137
2931
2778
1...

result:

ok 374196 numbers

Test #14:

score: 0
Accepted
time: 836ms
memory: 159592kb

input:

1 200000 500000
180482 179464
180482 193543
193543 198371
198371 169074
169074 164609
164609 168204
168204 197371
197371 173986
173986 182584
182584 173674
173674 181375
181375 190105
190105 186309
186309 189847
189847 168603
168603 99409
99409 185327
185327 172756
172756 99406
99406 185574
185574 1...

output:

10673
5634
7391
680
6687
12592
2003
4840
35
6181
17198
1362
3085
13905
1102
2869
1275
5446
4861
5644
2008
1518
20000
465
5127
2653
19817
779
2971
3892
5484
6267
1930
4344
263
789
7078
1447
2092
4322
3092
856
11362
19716
1105
2284
8702
4125
14956
11052
2786
4142
3437
9702
5492
3024
613
1707
16541
610...

result:

ok 374199 numbers

Subtask #5:

score: 30
Accepted

Test #15:

score: 30
Accepted
time: 1634ms
memory: 226280kb

input:

20 200000 1000000
13 10
13 5
19 5
19 20
15 10
15 6
12 6
12 3
8 10
8 2
1 20
1 11
14 10
14 16
18 3
18 7
4 3
9 10
9 17
194055 154514
194055 148156
148156 115271
115271 198116
198116 179433
179433 171975
171975 196600
196600 167194
167194 185078
185078 191409
191409 163496
163496 178243
178243 154093
15...

output:

459
5817
10120
7654
4894
19469
3577
16028
2835
7538
1131
9925
18495
497
11876
2132
9849
7576
7278
111
1850
7391
3350
6100
19488
16462
6207
1725
5922
5596
3820
1918
718
3319
2715
19890
5606
634
753
1301
15995
2973
1671
14675
5218
2639
118
1896
3266
1935
14603
4577
7219
5902
11027
4392
7461
9754
19632...

result:

ok 748402 numbers

Test #16:

score: 0
Accepted
time: 1556ms
memory: 220460kb

input:

20 200000 1000000
4 11
4 14
7 11
7 3
19 7
19 1
8 11
8 17
20 19
20 10
16 11
16 15
18 11
18 9
6 20
6 13
2 10
2 5
12 2
192848 167029
192848 155016
155016 137607
137607 147555
147555 183310
183310 190260
190260 191253
191253 125125
125125 125218
125218 90148
90148 189510
189510 188621
188621 161627
1616...

output:

3742
1793
19582
14116
5769
10973
19726
4592
5437
3220
1128
3
3090
7978
5246
2759
2166
3844
8938
6259
756
1037
732
5666
11435
6942
15500
5230
132
11540
11844
10295
6124
1952
6119
21
19789
7610
20
12
4332
1822
3836
463
51
13619
2050
2341
15409
10099
2366
14403
6773
15719
3
7263
2719
1397
2250
7794
726...

result:

ok 748399 numbers

Test #17:

score: 0
Accepted
time: 1611ms
memory: 228412kb

input:

20 200000 1000000
16 13
16 10
19 16
19 14
17 19
17 12
20 17
20 6
3 12
3 8
15 6
15 5
1 16
1 2
7 12
7 4
18 3
18 11
9 14
173636 192551
173636 175328
175328 195580
195580 190028
190028 185841
185841 166711
166711 191129
191129 176451
176451 198540
198540 161071
161071 111518
111518 190226
190226 192935
...

output:

5393
4985
1405
428
2519
8472
2843
3344
19817
19813
2688
17485
6109
11511
2
13705
6950
21
1376
5275
6296
4438
505
1397
2057
7725
2180
810
663
2378
19882
220
19909
64
4066
19680
248
1863
676
7288
4399
6140
3471
2866
5216
17732
14421
19233
3108
2724
7180
5096
4271
3788
3287
11413
1912
5904
10846
6468
3...

result:

ok 748410 numbers

Test #18:

score: 0
Accepted
time: 1495ms
memory: 221784kb

input:

20 200000 1000000
12 11
12 17
15 17
15 6
14 12
14 4
13 6
13 1
10 14
10 20
9 11
9 16
8 12
8 7
2 9
5 12
5 18
19 18
3 11
164560 192729
164560 147583
147583 166643
166643 154956
154956 180719
180719 162665
162665 196527
196527 177100
177100 168018
168018 165736
165736 172539
172539 175370
175370 195609
...

output:

3456
11518
5186
1497
2
2362
2661
5881
16872
15342
6
12
6472
1311
18427
141
4550
7412
326
5022
6132
3828
4097
18168
6189
1771
4783
13926
9751
5285
4444
5497
3344
4868
19951
21
2686
9470
1096
817
6053
6139
2564
8308
2001
5794
3913
7120
948
4446
4482
2156
5913
2
5210
3501
5690
1226
362
2947
1536
2400
7...

result:

ok 748394 numbers

Test #19:

score: 0
Accepted
time: 1503ms
memory: 218944kb

input:

20 200000 1000000
8 9
8 7
15 8
15 4
14 9
14 13
12 14
12 20
18 8
18 2
19 7
19 1
11 18
11 17
5 19
6 18
6 16
10 1
3 1
189919 162312
189919 190500
190500 159341
159341 159035
159035 101100
101100 172161
172161 176987
176987 193790
193790 151028
151028 184773
184773 189192
189192 181674
181674 171441
171...

output:

7775
4121
1219
19801
5287
3677
510
4915
2511
2932
2409
12222
4935
1119
1356
10299
86
2009
3790
6086
9923
193
1835
1099
21
241
1524
9344
10573
21
5778
3301
21
6816
2888
7581
1386
10752
7
6583
19368
2987
3470
1617
81
4001
11735
7409
5916
21
3598
21
2102
3939
5207
181
2
1430
18336
4527
3
19998
8666
254...

result:

ok 748397 numbers

Test #20:

score: 0
Accepted
time: 1553ms
memory: 216392kb

input:

20 200000 1000000
1 18
1 19
20 19
20 12
14 20
14 13
5 14
5 9
16 19
16 4
3 9
3 10
17 1
17 7
2 18
11 2
11 6
15 20
8 1
194864 187407
194864 168438
168438 145007
145007 187681
187681 151584
151584 199294
199294 195104
195104 195273
195273 187680
187680 175434
175434 183413
183413 198986
198986 178558
17...

output:

1270
11308
9834
5174
6296
5220
3739
8625
8695
10220
1174
15818
5195
1535
2378
1956
1002
2361
2579
7829
3499
796
4920
8210
4249
945
5519
8828
7101
4721
12008
6485
3508
80
1652
1597
3337
286
7039
882
1047
4083
5634
19690
6727
261
19919
1480
17662
5696
19920
8786
10532
1670
8658
184
247
1917
598
6537
9...

result:

ok 748409 numbers

Test #21:

score: 0
Accepted
time: 1388ms
memory: 208232kb

input:

20 200000 1000000
16 1
16 9
17 16
17 10
4 9
4 6
20 6
20 13
3 17
3 18
15 16
15 11
2 11
19 6
19 8
5 4
5 14
12 11
7 5
174114 187243
174114 31729
31729 178935
178935 196382
196382 158811
158811 183172
183172 112320
112320 187729
187729 178384
178384 143788
143788 145298
145298 193852
193852 160568
16056...

output:

9
100
100
44
9
100
100
100
100
2
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
89
100
100
100
100
100
100
100
100
100
100
100
100
100
100
18
100
100
98
100
100
100
3
2
100
100
100
100
100
100
100
51
100
100
100
100
100
100
100
100
100
100
100
87
100
28
100
5
2
100
100
19
100
100
18...

result:

ok 748406 numbers

Test #22:

score: 0
Accepted
time: 1412ms
memory: 201136kb

input:

20 200000 1000000
2 15
2 19
6 15
6 9
12 15
12 13
11 19
11 3
16 9
16 20
5 2
5 8
1 8
1 17
18 15
7 5
7 10
14 10
14 4
145168 199284
145168 194030
145168 164799
145168 183470
145168 198797
145168 155401
145168 192951
145168 194489
145168 169273
145168 156957
145168 118791
145168 169122
145168 138763
1451...

output:

100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
19
100
100
100
3
86
20
100
100
100
100
100
100
100
20
100
100
20
12
100
100
100
98
100
100
100
100
21
100
83
99
3
3
2
100
2
100
100
100
100
100
100
17
100
100
18
3
100
3
100
18
100
16
100
100
100
100
100
100
...

result:

ok 748404 numbers

Test #23:

score: 0
Accepted
time: 1798ms
memory: 229744kb

input:

20 200000 1000000
5 2
5 11
8 11
13 5
13 1
15 5
15 16
19 8
19 20
14 1
14 9
10 14
10 4
17 11
17 7
3 19
3 18
12 5
6 12
170690 192949
170690 174070
174070 144505
144505 175837
175837 188838
188838 170545
170545 57224
57224 173415
173415 162037
162037 131470
131470 190432
190432 191001
191001 195949
1959...

output:

100
100
100
100
16
100
90
100
100
100
100
100
100
100
100
100
100
99
100
100
100
100
100
100
100
100
100
100
100
72
100
100
100
100
100
100
100
100
100
100
100
100
18
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
100
61
100
100
100
100
100
100
100
100
100
100
75
100
100
100
100...

result:

ok 989888 numbers

Test #24:

score: 0
Accepted
time: 1852ms
memory: 267392kb

input:

20 200000 1000000
15 6
15 12
18 6
5 6
5 11
17 6
17 3
10 18
10 19
16 15
16 4
1 5
1 9
13 3
13 14
20 18
20 7
2 9
8 18
183682 192157
183682 189529
183682 130356
183682 99993
183682 187139
183682 188817
183682 199531
183682 146248
183682 159302
183682 195511
183682 166931
183682 143843
183682 197975
1836...

output:

30
30
30
30
13
30
30
30
30
30
30
30
30
30
30
30
13
30
30
30
30
30
30
30
14
13
30
30
30
30
30
14
29
30
13
30
13
30
13
30
30
30
30
30
30
30
30
30
13
30
30
30
13
14
14
30
30
30
30
14
14
30
30
30
13
30
30
30
30
30
30
30
30
30
30
30
30
14
30
30
15
30
30
15
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
30
...

result:

ok 989976 numbers