QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#645197#7926. Color Inversion on a Huge ChessboardAFLeartLey0103#AC ✓1182ms66304kbC++142.5kb2024-10-16 17:13:442024-10-16 17:13:56

Judging History

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

  • [2024-10-16 17:13:56]
  • 评测
  • 测评结果:AC
  • 用时:1182ms
  • 内存:66304kb
  • [2024-10-16 17:13:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn = 5e5+50;
int n, q;
class obj{
public:
  mutable int l, r;
  int color;
  friend bool operator<(obj a, obj b){ return a.r < b.r; }
};
int col[maxn], row[maxn];
set<obj> scol, srow;

void edit_col(int u){
  auto it = scol.lower_bound({0, u});
  int l = it->l, r = it->r, color = it->color;
  if(l == r){
    auto lit = it, rit = it;
    if(l != 1) lit--; if(r != n) rit++;
    int _l = lit->l, _r = rit->r;
    if(l != 1) scol.erase(lit); if(r != n) scol.erase(rit);
    scol.erase(it);
    scol.insert({_l, _r, color^1});
  }
  else if(l == u){
    if(l == 1) {
      it->l++; scol.insert({u, u, color^1});
    }
    else{
      auto lit = it; lit--;
      it->l++, lit->r++;
    }
  }
  else if(r == u){
    if(r == n) {
      it->r--; scol.insert({u, u, color^1});
    }
    else{
      auto rit = it; rit++;
      it->r--, rit->l--;
    }
  }
  else{
    scol.erase(it);
    scol.insert({l, u-1, color^1});
    scol.insert({u+1, r, color^1});
    scol.insert({u, u, color});
  }
}

void edit_row(int u){
  auto it = srow.lower_bound({0, u});
  int l = it->l, r = it->r, color = it->color;
  if(l == r){
    auto lit = it, rit = it;
    if(l != 1) lit--; if(r != n) rit++;
    int _l = lit->l, _r = rit->r;
    if(l != 1) srow.erase(lit); if(r != n) srow.erase(rit);
    srow.erase(it);
    srow.insert({_l, _r, color^1});
  }
  else if(l == u){
    if(l == 1) {
      it->l++;
      srow.insert({u, u, color^1});
    }
    else{
      auto lit = it; lit--;
      it->l++, lit->r++;
    }
  }
  else if(r == u){
    if(r == n) {
      it->r--;
      srow.insert({u, u, color^1});
    }
    else{
      auto rit = it; rit++;
      it->r--, rit->l--;
    }
  }
  else{
    srow.erase(it);
    srow.insert({l, u-1, color^1});
    srow.insert({u+1, r, color^1});
    srow.insert({u, u, color});
  }
}
signed main(){
  cin >> n >> q;
  for(int i = 1, id = 0; i <= n; ++ i, id ^= 1){
    scol.insert({i,i,id}); srow.insert({i,i,id});
  }
  while(q--){
    string s; cin >> s;
    int u; cin >> u;
    if(s[0] == 'R'){
      edit_row(u);
    }
    else {
      edit_col(u);
    }/*
       for(auto i:scol) cerr << i.l << ' ' << i.r << ' ' << i.color << '\n';
       for(auto i:scol) cerr << i.l << ' ' << i.r << ' ' << i.color << '\n';
       cerr << "ans:";*/
    cout << scol.size() * srow.size() << '\n';
  }
  return 0;
}

详细

Test #1:

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

input:

3 3
ROW 2
COLUMN 3
ROW 2

output:

3
2
6

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 90ms
memory: 28512kb

input:

200000 2
ROW 1
ROW 1

output:

39999800000
40000000000

result:

ok 2 lines

Test #3:

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

input:

1 1
COLUMN 1

output:

1

result:

ok single line: '1'

Test #4:

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

input:

1 100
COLUMN 1
COLUMN 1
ROW 1
ROW 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
ROW 1
COLUMN 1
COL...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1

result:

ok 100 lines

Test #5:

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

input:

2 100
COLUMN 2
ROW 1
COLUMN 2
COLUMN 2
ROW 2
ROW 1
COLUMN 1
COLUMN 1
COLUMN 1
ROW 1
ROW 1
ROW 1
COLUMN 1
ROW 2
COLUMN 1
COLUMN 2
COLUMN 1
ROW 1
ROW 2
ROW 1
COLUMN 2
ROW 2
ROW 2
COLUMN 2
COLUMN 1
ROW 2
COLUMN 2
ROW 1
ROW 2
ROW 1
ROW 1
COLUMN 2
COLUMN 2
COLUMN 2
COLUMN 2
ROW 2
ROW 1
ROW 1
COLUMN 1
ROW...

output:

2
1
2
1
2
1
2
1
2
4
2
4
2
1
2
1
2
4
2
4
2
1
2
4
2
1
2
4
2
4
2
1
2
1
2
4
2
4
2
1
2
1
2
1
2
4
2
4
2
4
2
4
2
4
2
1
2
1
2
1
2
4
2
1
2
4
2
4
2
1
2
1
2
4
2
1
2
4
2
1
2
4
2
1
2
4
2
4
2
1
2
4
2
1
2
4
2
4
2
4

result:

ok 100 lines

Test #6:

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

input:

3 100
ROW 1
ROW 1
COLUMN 3
ROW 3
ROW 2
COLUMN 2
ROW 3
COLUMN 3
COLUMN 2
COLUMN 1
ROW 3
ROW 2
ROW 2
COLUMN 3
ROW 3
COLUMN 2
COLUMN 2
ROW 2
COLUMN 3
COLUMN 1
COLUMN 2
COLUMN 2
ROW 1
ROW 1
COLUMN 3
ROW 2
COLUMN 2
COLUMN 3
ROW 3
COLUMN 1
ROW 3
COLUMN 2
COLUMN 1
ROW 3
ROW 3
COLUMN 2
COLUMN 2
COLUMN 1
ROW...

output:

6
9
6
4
4
4
2
1
3
2
4
4
4
2
1
3
1
3
6
9
3
9
6
9
6
2
2
1
2
4
2
2
3
6
3
1
3
2
4
4
2
4
4
6
9
6
4
4
6
9
6
4
2
4
4
4
6
9
6
9
6
3
2
2
6
4
6
9
6
4
2
1
2
3
6
4
2
2
4
4
4
4
4
4
6
4
4
4
2
1
2
3
2
4
2
3
2
4
2
3

result:

ok 100 lines

Test #7:

score: 0
Accepted
time: 248ms
memory: 3568kb

input:

1 500000
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
ROW 1
ROW 1
ROW 1
COLUMN 1
ROW 1
COLUMN 1
ROW 1
COLUMN 1
ROW 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
ROW 1
COLUMN 1
ROW 1
ROW 1
COLUMN 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
COLUMN 1
ROW 1
ROW 1
COLUMN 1
ROW 1
COLUMN...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 lines

Test #8:

score: 0
Accepted
time: 321ms
memory: 3584kb

input:

100 500000
ROW 61
COLUMN 9
COLUMN 12
COLUMN 53
ROW 33
ROW 92
COLUMN 6
COLUMN 60
COLUMN 18
ROW 67
COLUMN 79
ROW 35
ROW 12
ROW 48
ROW 28
ROW 91
ROW 44
COLUMN 11
COLUMN 45
ROW 13
COLUMN 61
ROW 75
COLUMN 15
ROW 75
COLUMN 86
ROW 52
COLUMN 7
ROW 36
COLUMN 13
COLUMN 42
COLUMN 99
ROW 8
COLUMN 8
COLUMN 40
CO...

output:

9800
9604
9408
9212
9024
8836
8648
8460
8272
8096
7912
7740
7568
7396
7224
7224
7052
7052
6888
6888
6888
6720
6560
6724
6560
6400
6400
6400
6400
6240
6080
5928
6084
5928
5772
5928
5772
5616
5460
5304
5148
5016
4884
4884
4752
4680
4680
4550
4410
4284
4158
4032
3904
4026
4026
3894
3762
3762
3876
3876
...

result:

ok 500000 lines

Test #9:

score: 0
Accepted
time: 1182ms
memory: 66112kb

input:

500000 500000
COLUMN 402110
COLUMN 19563
COLUMN 9425
COLUMN 365025
ROW 189381
COLUMN 399979
COLUMN 233971
ROW 327398
ROW 222106
COLUMN 435101
COLUMN 345343
COLUMN 424895
ROW 62920
ROW 228188
ROW 90499
ROW 326252
COLUMN 96648
ROW 315146
ROW 62918
COLUMN 116109
ROW 213729
COLUMN 383506
ROW 142029
COLU...

output:

249999000000
249998000000
249997000000
249996000000
249995000016
249994000020
249993000024
249992000048
249991000072
249990000084
249989000096
249988000108
249987000144
249986000180
249985000216
249984000252
249983000280
249982000320
249981000360
249980000396
249979000440
249978000480
249977000528
2...

result:

ok 500000 lines

Test #10:

score: 0
Accepted
time: 1105ms
memory: 66008kb

input:

500000 500000
ROW 3666
ROW 19734
ROW 494660
ROW 174051
COLUMN 350072
ROW 306516
COLUMN 120649
ROW 444239
COLUMN 318614
COLUMN 455304
ROW 433831
ROW 344173
ROW 334122
ROW 347475
ROW 44995
ROW 19168
COLUMN 484089
ROW 427892
ROW 329140
ROW 104200
COLUMN 494231
ROW 288323
ROW 183007
ROW 57430
ROW 434219...

output:

249999000000
249998000000
249997000000
249996000000
249995000016
249994000020
249993000040
249992000048
249991000072
249990000096
249989000112
249988000128
249987000144
249986000160
249985000176
249984000192
249983000240
249982000260
249981000280
249980000300
249979000360
249978000384
249977000408
2...

result:

ok 500000 lines

Test #11:

score: 0
Accepted
time: 993ms
memory: 66040kb

input:

500000 500000
COLUMN 17785
ROW 270549
ROW 225472
ROW 168991
COLUMN 185277
COLUMN 458795
ROW 235223
COLUMN 234279
ROW 404851
ROW 144211
COLUMN 416575
COLUMN 369414
ROW 170027
ROW 43313
COLUMN 155095
COLUMN 444999
COLUMN 482631
COLUMN 240889
ROW 361481
COLUMN 401852
COLUMN 120206
ROW 420865
COLUMN 909...

output:

249999000000
249998000004
249997000008
249996000012
249995000024
249994000036
249993000048
249992000064
249991000080
249990000096
249989000120
249988000144
249987000168
249986000192
249985000224
249984000256
249983000288
249982000320
249981000360
249980000396
249979000432
249978000480
249977000520
2...

result:

ok 500000 lines

Test #12:

score: 0
Accepted
time: 740ms
memory: 66076kb

input:

500000 500000
ROW 26
COLUMN 499934
COLUMN 499938
ROW 499995
ROW 499904
COLUMN 96
COLUMN 15
ROW 499927
ROW 499916
COLUMN 499963
ROW 13
COLUMN 499929
COLUMN 93
ROW 59
COLUMN 80
ROW 86
COLUMN 499964
COLUMN 499922
ROW 1
COLUMN 13
ROW 499967
COLUMN 499914
ROW 499937
ROW 67
ROW 499972
COLUMN 499957
COLUMN...

output:

249999000000
249998000004
249997000008
249996000016
249995000024
249994000036
249993000048
249992000064
249991000080
249990000100
249989000120
249988000144
249987000168
249986000196
249985000224
249984000256
249984000256
249983000288
249982500306
249981500340
249980500380
249979500418
249978500462
2...

result:

ok 500000 lines

Test #13:

score: 0
Accepted
time: 979ms
memory: 66304kb

input:

500000 499999
COLUMN 361956
ROW 145517
ROW 15281
ROW 388636
ROW 152103
COLUMN 402893
COLUMN 80639
COLUMN 139320
COLUMN 27667
COLUMN 82556
COLUMN 63716
COLUMN 113529
ROW 301173
COLUMN 301174
ROW 345006
COLUMN 73724
COLUMN 467291
COLUMN 265401
ROW 190250
COLUMN 247710
ROW 215696
ROW 108449
ROW 17317
C...

output:

249999000000
249998000004
249997000008
249996000012
249995000016
249994000032
249993000048
249992000064
249991000080
249990000096
249989000112
249988000128
249987000160
249986000180
249985000216
249984000240
249983000264
249982000288
249981000336
249980000364
249979000416
249978000468
249977000520
2...

result:

ok 499999 lines

Test #14:

score: 0
Accepted
time: 1040ms
memory: 66064kb

input:

499999 499998
ROW 37459
ROW 171749
ROW 208323
COLUMN 199541
ROW 370190
COLUMN 197644
COLUMN 137395
COLUMN 374294
ROW 226434
ROW 117992
ROW 36952
COLUMN 441379
ROW 387901
ROW 34836
ROW 292806
COLUMN 6341
COLUMN 319407
ROW 39510
ROW 453907
ROW 188006
COLUMN 303966
COLUMN 418344
ROW 68254
ROW 211294
RO...

output:

249998000003
249997000005
249996000007
249995000021
249994000027
249993000045
249992000063
249991000081
249990000099
249989000117
249988000135
249987000165
249986000187
249985000209
249984000231
249983000273
249982000315
249981000345
249980000375
249979000405
249978000459
249977000513
249976000551
2...

result:

ok 499998 lines

Test #15:

score: 0
Accepted
time: 1059ms
memory: 66216kb

input:

499998 500000
COLUMN 249830
COLUMN 402253
COLUMN 465122
COLUMN 289415
ROW 27903
ROW 21905
COLUMN 276696
COLUMN 420042
ROW 188020
COLUMN 269081
COLUMN 55576
ROW 36072
ROW 216367
ROW 218760
COLUMN 395729
ROW 342127
ROW 335919
COLUMN 196443
ROW 316458
ROW 6906
COLUMN 260212
COLUMN 313029
ROW 91177
ROW ...

output:

249997000008
249996000012
249995000016
249994000020
249993000040
249992000060
249991000072
249990000084
249989000112
249988000128
249987000144
249986000180
249985000216
249984000252
249983000280
249982000320
249981000360
249980000396
249979000440
249978000484
249977000528
249976000572
249975000624
2...

result:

ok 500000 lines

Test #16:

score: 0
Accepted
time: 1016ms
memory: 66072kb

input:

499997 499999
COLUMN 12784
ROW 459678
ROW 120357
ROW 436589
ROW 109752
COLUMN 388713
ROW 278365
ROW 410679
ROW 313823
ROW 236489
ROW 199269
COLUMN 152723
ROW 193069
ROW 165399
ROW 172434
COLUMN 129061
COLUMN 467004
ROW 241698
ROW 246044
ROW 50098
ROW 330040
COLUMN 269348
COLUMN 355851
COLUMN 481716
...

output:

249996000015
249995000025
249994000035
249993000045
249992000055
249991000077
249990000091
249989000105
249988000119
249987000133
249986000147
249985000189
249984000207
249983000225
249982000243
249981000297
249980000351
249979000377
249978000403
249977000429
249976000455
249975000525
249974000595
2...

result:

ok 499999 lines

Test #17:

score: 0
Accepted
time: 774ms
memory: 66076kb

input:

499996 499998
COLUMN 221927
COLUMN 137251
COLUMN 132017
COLUMN 391829
COLUMN 374803
COLUMN 459287
COLUMN 289341
COLUMN 211021
COLUMN 185245
COLUMN 295461
COLUMN 311743
COLUMN 338441
COLUMN 437841
COLUMN 315347
COLUMN 12557
COLUMN 15155
COLUMN 455681
COLUMN 81303
COLUMN 67745
COLUMN 430799
COLUMN 151...

output:

249995000024
249994000032
249993000040
249992000048
249991000056
249990000064
249989000072
249988000080
249987000088
249986000096
249985000104
249984000112
249983000120
249982000128
249981000136
249980000144
249979000152
249978000160
249977000168
249976000176
249975000184
249974000192
249973000200
2...

result:

ok 499998 lines

Test #18:

score: 0
Accepted
time: 772ms
memory: 66216kb

input:

500000 500000
COLUMN 391846
COLUMN 457784
COLUMN 382514
COLUMN 1420
COLUMN 17932
COLUMN 118344
COLUMN 209492
COLUMN 445410
COLUMN 153150
COLUMN 386002
COLUMN 40646
COLUMN 89470
COLUMN 159860
COLUMN 136748
COLUMN 50072
COLUMN 5654
COLUMN 268284
COLUMN 428606
COLUMN 430802
COLUMN 462970
COLUMN 374966
...

output:

249999000000
249998000000
249997000000
249996000000
249995000000
249994000000
249993000000
249992000000
249991000000
249990000000
249989000000
249988000000
249987000000
249986000000
249985000000
249984000000
249983000000
249982000000
249981000000
249980000000
249979000000
249978000000
249977000000
2...

result:

ok 500000 lines

Test #19:

score: 0
Accepted
time: 771ms
memory: 66076kb

input:

499999 499998
ROW 333103
ROW 191439
ROW 356679
ROW 302501
ROW 374513
ROW 371949
ROW 52569
ROW 366999
ROW 39503
ROW 222053
ROW 399271
ROW 162879
ROW 227791
ROW 148787
ROW 82169
ROW 467333
ROW 66439
ROW 205245
ROW 31095
ROW 191103
ROW 72715
ROW 170183
ROW 1917
ROW 309711
ROW 493723
ROW 389133
ROW 2383...

output:

249998000003
249997000005
249996000007
249995000009
249994000011
249993000013
249992000015
249991000017
249990000019
249989000021
249988000023
249987000025
249986000027
249985000029
249984000031
249983000033
249982000035
249981000037
249980000039
249979000041
249978000043
249977000045
249976000047
2...

result:

ok 499998 lines

Test #20:

score: 0
Accepted
time: 694ms
memory: 66040kb

input:

499998 499997
ROW 477400
ROW 14204
ROW 430866
ROW 158718
ROW 235878
ROW 119084
ROW 372676
ROW 317032
ROW 479646
ROW 161578
ROW 107590
ROW 422756
ROW 498218
ROW 295372
ROW 360134
ROW 168548
ROW 33716
ROW 120380
ROW 18856
ROW 306376
ROW 192044
ROW 18762
ROW 180624
ROW 244858
ROW 248818
ROW 112938
ROW ...

output:

249997000008
249996000012
249995000016
249994000020
249993000024
249992000028
249991000032
249990000036
249989000040
249988000044
249987000048
249986000052
249985000056
249984000060
249983000064
249982000068
249981000072
249980000076
249979000080
249978000084
249977000088
249976000092
249975000096
2...

result:

ok 499997 lines

Test #21:

score: 0
Accepted
time: 764ms
memory: 66068kb

input:

499997 499999
ROW 241905
ROW 194971
ROW 311601
ROW 187243
ROW 356955
ROW 359057
ROW 414963
ROW 415183
ROW 20037
ROW 195865
ROW 264307
ROW 18199
ROW 15521
ROW 176717
ROW 465111
ROW 131577
ROW 328295
ROW 107271
ROW 173773
ROW 267785
ROW 388825
ROW 96429
ROW 235341
ROW 225251
ROW 74481
ROW 396059
ROW 3...

output:

249996000015
249995000021
249994000027
249993000033
249992000039
249991000045
249990000051
249989000057
249988000063
249987000069
249986000075
249985000081
249984000087
249983000093
249982000099
249981000105
249980000111
249979000117
249978000123
249977000129
249976000135
249975000141
249974000147
2...

result:

ok 499999 lines

Test #22:

score: 0
Accepted
time: 678ms
memory: 66092kb

input:

499996 499998
ROW 495850
ROW 139754
ROW 330554
ROW 23048
ROW 49180
ROW 217044
ROW 319244
ROW 74218
ROW 253908
ROW 101924
ROW 240100
ROW 68716
ROW 78574
ROW 276258
ROW 163444
ROW 288526
ROW 362238
ROW 103554
ROW 177808
ROW 317868
ROW 487484
ROW 289864
ROW 498974
ROW 390496
ROW 211524
ROW 194334
ROW 2...

output:

249995000024
249994000032
249993000040
249992000048
249991000056
249990000064
249989000072
249988000080
249987000088
249986000096
249985000104
249984000112
249983000120
249982000128
249981000136
249980000144
249979000152
249978000160
249977000168
249976000176
249975000184
249974000192
249973000200
2...

result:

ok 499998 lines

Test #23:

score: 0
Accepted
time: 755ms
memory: 66068kb

input:

500000 499998
COLUMN 454493
COLUMN 275347
COLUMN 93167
COLUMN 239031
COLUMN 297331
COLUMN 330547
COLUMN 145879
COLUMN 464961
COLUMN 85091
COLUMN 380695
COLUMN 499293
COLUMN 185081
COLUMN 14937
COLUMN 266947
COLUMN 72177
COLUMN 413719
COLUMN 80039
COLUMN 127161
COLUMN 126251
COLUMN 299039
COLUMN 4720...

output:

249999000000
249998000000
249997000000
249996000000
249995000000
249994000000
249993000000
249992000000
249991000000
249990000000
249989000000
249988000000
249987000000
249986000000
249985000000
249984000000
249983000000
249982000000
249981000000
249980000000
249979000000
249978000000
249977000000
2...

result:

ok 499998 lines

Test #24:

score: 0
Accepted
time: 802ms
memory: 66280kb

input:

499999 499999
COLUMN 336956
COLUMN 59064
COLUMN 210886
COLUMN 214860
COLUMN 246524
COLUMN 408646
COLUMN 211012
COLUMN 135378
COLUMN 403078
COLUMN 176998
COLUMN 440034
COLUMN 272272
COLUMN 338984
COLUMN 429788
COLUMN 45882
COLUMN 496708
COLUMN 391174
COLUMN 165800
COLUMN 67146
COLUMN 252086
COLUMN 82...

output:

249998000003
249997000005
249996000007
249995000009
249994000011
249993000013
249992000015
249991000017
249990000019
249989000021
249988000023
249987000025
249986000027
249985000029
249984000031
249983000033
249982000035
249981000037
249980000039
249979000041
249978000043
249977000045
249976000047
2...

result:

ok 499999 lines

Test #25:

score: 0
Accepted
time: 865ms
memory: 66036kb

input:

499998 499999
COLUMN 198613
COLUMN 145943
COLUMN 230815
COLUMN 466085
COLUMN 326079
COLUMN 426993
COLUMN 453455
COLUMN 406171
COLUMN 217713
COLUMN 152689
COLUMN 38177
COLUMN 237645
COLUMN 389911
COLUMN 300835
COLUMN 310875
COLUMN 391625
COLUMN 207639
COLUMN 133463
COLUMN 346269
COLUMN 300177
COLUMN ...

output:

249997000008
249996000012
249995000016
249994000020
249993000024
249992000028
249991000032
249990000036
249989000040
249988000044
249987000048
249986000052
249985000056
249984000060
249983000064
249982000068
249981000072
249980000076
249979000080
249978000084
249977000088
249976000092
249975000096
2...

result:

ok 499999 lines

Test #26:

score: 0
Accepted
time: 798ms
memory: 65996kb

input:

499997 499998
COLUMN 149502
COLUMN 225682
COLUMN 324018
COLUMN 426910
COLUMN 141204
COLUMN 343314
COLUMN 280690
COLUMN 166316
COLUMN 371010
COLUMN 408958
COLUMN 395832
COLUMN 402814
COLUMN 460334
COLUMN 109140
COLUMN 437706
COLUMN 264974
COLUMN 460928
COLUMN 303962
COLUMN 182876
COLUMN 189494
COLUMN...

output:

249996000015
249995000021
249994000027
249993000033
249992000039
249991000045
249990000051
249989000057
249988000063
249987000069
249986000075
249985000081
249984000087
249983000093
249982000099
249981000105
249980000111
249979000117
249978000123
249977000129
249976000135
249975000141
249974000147
2...

result:

ok 499998 lines

Test #27:

score: 0
Accepted
time: 775ms
memory: 65952kb

input:

499996 500000
ROW 489891
ROW 174233
ROW 271817
ROW 301429
ROW 937
ROW 238831
ROW 209133
ROW 404877
ROW 13383
ROW 267123
ROW 4379
ROW 460011
ROW 485835
ROW 217571
ROW 495273
ROW 498491
ROW 459477
ROW 332703
ROW 54397
ROW 455555
ROW 180889
ROW 143409
ROW 173055
ROW 464851
ROW 114795
ROW 258979
ROW 128...

output:

249995000024
249994000032
249993000040
249992000048
249991000056
249990000064
249989000072
249988000080
249987000088
249986000096
249985000104
249984000112
249983000120
249982000128
249981000136
249980000144
249979000152
249978000160
249977000168
249976000176
249975000184
249974000192
249973000200
2...

result:

ok 500000 lines

Test #28:

score: 0
Accepted
time: 703ms
memory: 66108kb

input:

500000 499999
ROW 120564
ROW 385196
ROW 310532
ROW 24124
ROW 372644
ROW 227126
ROW 448170
ROW 158132
ROW 191434
ROW 307140
ROW 362556
ROW 435438
ROW 388536
ROW 201910
ROW 163054
ROW 43630
ROW 338318
ROW 349564
ROW 128192
ROW 353930
ROW 163400
ROW 296554
ROW 453152
ROW 50502
ROW 369114
ROW 470546
ROW...

output:

249999000000
249998000000
249997000000
249996000000
249995000000
249994000000
249993000000
249992000000
249991000000
249990000000
249989000000
249988000000
249987000000
249986000000
249985000000
249984000000
249983000000
249982000000
249981000000
249980000000
249979000000
249978000000
249977000000
2...

result:

ok 499999 lines

Test #29:

score: 0
Accepted
time: 997ms
memory: 66020kb

input:

499999 500000
ROW 57111
COLUMN 346799
ROW 136413
ROW 348001
ROW 250323
COLUMN 380103
ROW 399741
COLUMN 463761
COLUMN 10547
COLUMN 414681
ROW 30289
ROW 124891
ROW 41667
ROW 314835
COLUMN 407729
ROW 367547
COLUMN 64479
ROW 179089
ROW 293529
ROW 369907
ROW 415715
COLUMN 420263
COLUMN 431793
COLUMN 2972...

output:

249998000003
249997000009
249996000015
249995000021
249994000027
249993000045
249992000055
249991000077
249990000099
249989000121
249988000143
249987000165
249986000187
249985000209
249984000247
249983000273
249982000315
249981000345
249980000375
249979000405
249978000435
249977000493
249976000551
2...

result:

ok 500000 lines

Test #30:

score: 0
Accepted
time: 978ms
memory: 66068kb

input:

499998 499998
COLUMN 464655
COLUMN 470161
COLUMN 191749
ROW 425004
ROW 464368
ROW 459186
COLUMN 454643
COLUMN 491697
COLUMN 340175
COLUMN 349269
ROW 28170
ROW 68716
COLUMN 394637
COLUMN 145867
ROW 315604
ROW 113158
COLUMN 420335
COLUMN 137051
ROW 155556
ROW 134382
COLUMN 402471
ROW 114998
COLUMN 189...

output:

249997000008
249996000012
249995000016
249994000032
249993000048
249992000064
249991000080
249990000096
249989000112
249988000128
249987000160
249986000192
249985000216
249984000240
249983000280
249982000320
249981000352
249980000384
249979000432
249978000480
249977000520
249976000572
249975000616
2...

result:

ok 499998 lines

Test #31:

score: 0
Accepted
time: 960ms
memory: 66112kb

input:

499997 499997
COLUMN 15086
ROW 497887
COLUMN 157020
COLUMN 292540
ROW 486829
COLUMN 141142
COLUMN 209826
COLUMN 24844
COLUMN 366522
COLUMN 214672
ROW 59995
COLUMN 435388
COLUMN 183048
ROW 393929
COLUMN 330508
ROW 242289
ROW 458315
ROW 13621
ROW 479081
COLUMN 204922
COLUMN 337444
COLUMN 196858
ROW 12...

output:

249996000015
249995000025
249994000035
249993000045
249992000063
249991000077
249990000091
249989000105
249988000119
249987000133
249986000171
249985000189
249984000207
249983000253
249982000275
249981000325
249980000375
249979000425
249978000475
249977000513
249976000551
249975000589
249974000651
2...

result:

ok 499997 lines

Test #32:

score: 0
Accepted
time: 963ms
memory: 66292kb

input:

499996 499996
ROW 81934
ROW 329740
ROW 68992
ROW 131800
COLUMN 279366
ROW 326430
ROW 86588
COLUMN 194692
COLUMN 79722
ROW 498114
COLUMN 447544
ROW 230440
ROW 375576
COLUMN 299242
ROW 124966
COLUMN 435772
COLUMN 2564
COLUMN 89190
ROW 448340
COLUMN 211566
COLUMN 343096
COLUMN 358306
COLUMN 87010
ROW 9...

output:

249995000024
249994000032
249993000040
249992000048
249991000072
249990000084
249989000096
249988000128
249987000160
249986000180
249985000216
249984000240
249983000264
249982000308
249981000336
249980000384
249979000432
249978000480
249977000520
249976000572
249975000624
249974000676
249973000728
2...

result:

ok 499996 lines

Test #33:

score: 0
Accepted
time: 235ms
memory: 3784kb

input:

1 500000
ROW 1
ROW 1
COLUMN 1
COLUMN 1
COLUMN 1
ROW 1
ROW 1
COLUMN 1
ROW 1
ROW 1
ROW 1
ROW 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
COLUMN 1
ROW 1
ROW 1
ROW 1
ROW 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
ROW 1
ROW 1
COLUMN 1
ROW 1
COLUMN 1
ROW 1
COLUMN 1
COLUMN 1
COLUMN 1
ROW 1
ROW 1
ROW...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 500000 lines

Test #34:

score: 0
Accepted
time: 252ms
memory: 3612kb

input:

2 499999
ROW 1
ROW 1
COLUMN 2
ROW 2
COLUMN 1
COLUMN 2
ROW 2
COLUMN 1
ROW 1
ROW 1
ROW 2
COLUMN 1
ROW 2
COLUMN 2
COLUMN 2
COLUMN 2
COLUMN 1
COLUMN 1
ROW 1
ROW 1
ROW 1
ROW 1
COLUMN 2
ROW 2
COLUMN 2
ROW 2
ROW 1
COLUMN 1
ROW 1
COLUMN 2
ROW 1
ROW 1
ROW 1
COLUMN 1
ROW 1
ROW 2
ROW 2
COLUMN 2
COLUMN 2
ROW 2
...

output:

2
4
2
1
2
1
2
4
2
4
2
1
2
4
2
4
2
4
2
4
2
4
2
1
2
4
2
1
2
4
2
4
2
1
2
1
2
4
2
1
2
4
2
1
2
4
2
4
2
1
2
1
2
4
2
4
2
4
2
1
2
1
2
1
2
1
2
4
2
4
2
1
2
1
2
4
2
4
2
4
2
4
2
1
2
4
2
1
2
4
2
4
2
4
2
1
2
4
2
1
2
4
2
1
2
4
2
1
2
4
2
1
2
1
2
1
2
1
2
1
2
4
2
4
2
1
2
1
2
4
2
1
2
4
2
1
2
1
2
4
2
1
2
4
2
4
2
1
2
1
...

result:

ok 499999 lines

Test #35:

score: 0
Accepted
time: 288ms
memory: 3616kb

input:

3 499998
COLUMN 1
COLUMN 1
COLUMN 2
ROW 1
COLUMN 2
COLUMN 1
COLUMN 3
ROW 2
ROW 1
COLUMN 2
COLUMN 2
ROW 2
ROW 3
ROW 3
COLUMN 1
COLUMN 2
COLUMN 1
COLUMN 3
ROW 1
COLUMN 2
COLUMN 2
ROW 1
ROW 3
COLUMN 1
COLUMN 2
ROW 1
COLUMN 1
ROW 3
COLUMN 1
ROW 1
COLUMN 2
COLUMN 2
ROW 2
ROW 2
COLUMN 3
COLUMN 2
ROW 1
COL...

output:

6
9
3
2
6
4
2
2
1
3
1
3
2
3
6
6
9
6
4
4
4
6
4
2
6
3
2
4
6
9
3
9
3
9
6
6
4
6
4
6
4
4
6
9
6
6
9
3
2
1
2
3
6
4
2
1
2
6
9
3
9
6
6
3
2
2
3
9
6
4
6
6
3
6
3
9
6
2
4
4
4
4
2
6
2
6
3
9
6
3
6
3
6
9
6
9
6
6
2
3
6
6
4
6
3
2
4
4
4
6
9
6
6
6
9
6
4
6
2
4
2
4
2
3
2
3
9
3
9
6
3
1
3
6
4
4
4
2
1
2
3
9
3
1
2
2
1
2
3
2
...

result:

ok 499998 lines

Test #36:

score: 0
Accepted
time: 583ms
memory: 65952kb

input:

499997 500000
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN 1
COLUMN ...

output:

249996500012
249997000009
249996500012
249997000009
249996500012
249997000009
249996500012
249997000009
249996500012
249997000009
249996500012
249997000009
249996500012
249997000009
249996500012
249997000009
249996500012
249997000009
249996500012
249997000009
249996500012
249997000009
249996500012
2...

result:

ok 500000 lines

Test #37:

score: 0
Accepted
time: 538ms
memory: 66072kb

input:

499996 499999
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW 1
ROW ...

output:

249995500020
249996000016
249995500020
249996000016
249995500020
249996000016
249995500020
249996000016
249995500020
249996000016
249995500020
249996000016
249995500020
249996000016
249995500020
249996000016
249995500020
249996000016
249995500020
249996000016
249995500020
249996000016
249995500020
2...

result:

ok 499999 lines

Test #38:

score: 0
Accepted
time: 712ms
memory: 66216kb

input:

500000 499998
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN 500000
COLUMN...

output:

249999500000
250000000000
249999500000
250000000000
249999500000
250000000000
249999500000
250000000000
249999500000
250000000000
249999500000
250000000000
249999500000
250000000000
249999500000
250000000000
249999500000
250000000000
249999500000
250000000000
249999500000
250000000000
249999500000
2...

result:

ok 499998 lines

Test #39:

score: 0
Accepted
time: 667ms
memory: 66068kb

input:

499999 500000
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
ROW 499999
...

output:

249998500002
249999000001
249998500002
249999000001
249998500002
249999000001
249998500002
249999000001
249998500002
249999000001
249998500002
249999000001
249998500002
249999000001
249998500002
249999000001
249998500002
249999000001
249998500002
249999000001
249998500002
249999000001
249998500002
2...

result:

ok 500000 lines

Test #40:

score: 0
Accepted
time: 656ms
memory: 66220kb

input:

499998 499999
COLUMN 499998
ROW 499998
COLUMN 1
ROW 499998
ROW 1
COLUMN 1
COLUMN 1
ROW 1
COLUMN 499998
COLUMN 1
COLUMN 1
ROW 1
COLUMN 1
ROW 1
ROW 499998
COLUMN 1
ROW 499998
ROW 499998
COLUMN 499998
ROW 499998
COLUMN 1
COLUMN 1
ROW 499998
COLUMN 1
COLUMN 499998
ROW 499998
ROW 1
ROW 499998
COLUMN 4999...

output:

249997500006
249997000009
249996500012
249997000008
249996500012
249997000009
249996500012
249997000008
249997500006
249998000004
249997500006
249997000009
249997500006
249998000004
249997500006
249997000009
249997500006
249997000009
249996500012
249997000008
249997500006
249997000008
249996500012
2...

result:

ok 499999 lines

Test #41:

score: 0
Accepted
time: 687ms
memory: 66068kb

input:

499997 499998
ROW 499997
ROW 1
COLUMN 1
COLUMN 499997
ROW 499997
ROW 1
COLUMN 1
ROW 1
ROW 1
COLUMN 1
COLUMN 499997
COLUMN 1
ROW 499997
ROW 1
ROW 1
COLUMN 499997
ROW 1
COLUMN 1
ROW 1
ROW 499997
ROW 499997
ROW 499997
COLUMN 1
ROW 499997
COLUMN 499997
COLUMN 499997
COLUMN 499997
COLUMN 499997
ROW 49999...

output:

249996500012
249996000015
249995500020
249995000025
249995500020
249996000015
249996500012
249996000016
249996500012
249996000015
249996500012
249997000009
249996500012
249996000015
249996500012
249996000016
249995500020
249995000025
249995500020
249996000015
249995500020
249996000015
249996500012
2...

result:

ok 499998 lines

Test #42:

score: 0
Accepted
time: 595ms
memory: 66072kb

input:

499996 499996
COLUMN 1
COLUMN 2
COLUMN 3
COLUMN 4
COLUMN 5
COLUMN 6
COLUMN 7
COLUMN 8
COLUMN 9
COLUMN 10
COLUMN 11
COLUMN 12
COLUMN 13
COLUMN 14
COLUMN 15
COLUMN 16
COLUMN 17
COLUMN 18
COLUMN 19
COLUMN 20
COLUMN 21
COLUMN 22
COLUMN 23
COLUMN 24
COLUMN 25
COLUMN 26
COLUMN 27
COLUMN 28
COLUMN 29
COLUM...

output:

249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
249995500020
2...

result:

ok 499996 lines

Test #43:

score: 0
Accepted
time: 616ms
memory: 66004kb

input:

500000 500000
ROW 1
ROW 2
ROW 3
ROW 4
ROW 5
ROW 6
ROW 7
ROW 8
ROW 9
ROW 10
ROW 11
ROW 12
ROW 13
ROW 14
ROW 15
ROW 16
ROW 17
ROW 18
ROW 19
ROW 20
ROW 21
ROW 22
ROW 23
ROW 24
ROW 25
ROW 26
ROW 27
ROW 28
ROW 29
ROW 30
ROW 31
ROW 32
ROW 33
ROW 34
ROW 35
ROW 36
ROW 37
ROW 38
ROW 39
ROW 40
ROW 41
ROW 42
R...

output:

249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
249999500000
2...

result:

ok 500000 lines

Test #44:

score: 0
Accepted
time: 601ms
memory: 66036kb

input:

499999 499999
COLUMN 499999
COLUMN 499998
COLUMN 499997
COLUMN 499996
COLUMN 499995
COLUMN 499994
COLUMN 499993
COLUMN 499992
COLUMN 499991
COLUMN 499990
COLUMN 499989
COLUMN 499988
COLUMN 499987
COLUMN 499986
COLUMN 499985
COLUMN 499984
COLUMN 499983
COLUMN 499982
COLUMN 499981
COLUMN 499980
COLUMN...

output:

249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
249998500002
2...

result:

ok 499999 lines

Test #45:

score: 0
Accepted
time: 621ms
memory: 66104kb

input:

499998 499998
ROW 499998
ROW 499997
ROW 499996
ROW 499995
ROW 499994
ROW 499993
ROW 499992
ROW 499991
ROW 499990
ROW 499989
ROW 499988
ROW 499987
ROW 499986
ROW 499985
ROW 499984
ROW 499983
ROW 499982
ROW 499981
ROW 499980
ROW 499979
ROW 499978
ROW 499977
ROW 499976
ROW 499975
ROW 499974
ROW 499973
...

output:

249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
249997500006
2...

result:

ok 499998 lines