QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#121444#1146. Railsomethingnew#100 ✓4ms4416kbC++207.1kb2023-07-08 06:54:062024-07-04 00:30:47

Judging History

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

  • [2024-07-04 00:30:47]
  • 评测
  • 测评结果:100
  • 用时:4ms
  • 内存:4416kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-08 06:54:06]
  • 提交

answer

//  ↘ ⬇ ⬇ ⬇ ⬇ ⬇ ↙
//  ➡ @roadfromroi ⬅
//  ↗ ⬆ ⬆ ⬆ ⬆ ⬆ ↖
#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include <unistd.h>
#include "array"
#include "set"
#define all(x) x.begin(), x.end()
using namespace std;
/* This is sample grader for the contestant getDistance*/
#include "rail.h"
int getdst(int frst, int x, int fromleft, set<pair<int, int>> &lftcnt, set<pair<int, int>> &rgtcnt) {
    if (fromleft) {
        if (frst <= x) {
            return x - frst;
        } else {
            auto it1 = lftcnt.lower_bound({frst, 0});
            if (it1 == lftcnt.end())
                return -1;
            pair<int, int> pos = *it1;
            int res = pos.first - frst;
            auto it2 = rgtcnt.lower_bound({x-1, 100001});
            if (it2 == rgtcnt.begin())
                return -1;
            pair<int, int> pos2 = *(--it2);
            res += pos.first - pos2.first;
            res += x - pos2.first;
            return res;
        }
    } else {
        auto it1 = lftcnt.lower_bound({max(frst+1, x+1), 0});
        if (it1 == lftcnt.end())
            return -1;
        pair<int, int> pos = *it1;
        int res = pos.first - frst + pos.first - x;
        return res;
    }
}
int getdst2(int frst, int x, set<pair<int, int>> &lftcnt, set<pair<int, int>> &rgtcnt) {
    auto it1 = rgtcnt.lower_bound({min(x+1, frst+1), 0});
    if (it1 == rgtcnt.begin())
        return -1;
    pair<int, int> pos = *(--it1);
    int res = - pos.first + frst - pos.first + x;
    return res;
}
void findLocation(int n, int first, int location[], int stype[]) {
    location[0] = first;
    stype[0] = 1;
    vector<pair<int, int>> resba;
    for (int i = 1; i < n; ++i) {
        resba.push_back({getDistance(0, i), i});
    }
    sort(all(resba));
    set<pair<int, int>> lftcnt, rgtcnt;
    rgtcnt.insert({first, 0});
    for (auto i : resba) {
        if (lftcnt.empty()) {
            lftcnt.insert({i.first + first, i.second});
            location[i.second] = i.first + first;
            stype[i.second] = 2;
        } else {
            // cout << i.first << ' ' << i.second << '\n';
            //  cout << -v2 + lftcnt.rbegin()->first << '\n';
            int v2 = getDistance(lftcnt.rbegin()->second, i.second);
            int v3 = getDistance(rgtcnt.begin()->second, i.second);
            //  cout << v2 + rgtcnt.begin()->first << '\n';
            int op1 = -v2 + lftcnt.rbegin()->first;
            int op2 = v3 + rgtcnt.begin()->first;
            bool tr1 = 1, tr2 = 1;
            if (getdst(first, op2, 1, lftcnt, rgtcnt) != i.first) {
                tr2 = 0;
            }
            if (lftcnt.rbegin()->first > op2 and getdst2(lftcnt.rbegin()->first, op2, lftcnt, rgtcnt) != v2) {
                tr2 = 0;
            }
            //cout << i.first << ' ' << first << ' ' << op1 << ' ' << getdst(first, op1, 0, lftcnt, rgtcnt) << '\n';
            if (getdst(first, op1, 0, lftcnt, rgtcnt) != i.first) {
                tr1 = 0;
            }
            if (tr2 and op2 < first and getdst(first, op2, 1, lftcnt, rgtcnt) == i.first) {
                tr1 = 0;
            }//cout << tr1 << ' ' << tr2 << '\n';
            //cout << "(" << op1 << ' ' << op2 << ")\n";
                //cout << "No\n";
            if (tr1) {
                rgtcnt.insert({op1, i.second});
                location[i.second] = op1;
                stype[i.second] = 1;
              //  cout << i.second << "->" << op1 << '\n';
              //  cout << i.second << "->" << 1 << '\n';
            } else {
                lftcnt.insert({op2, i.second});
                location[i.second] = op2;
                stype[i.second] = 2;
             //   cout << i.second << "->" << op2 << '\n';
             //   cout << i.second << "->" << 2 << '\n';
            }
        }
    }
}
/*
typedef struct Station {
    int index;
    int type;
    int location;
    int L,R;
}STATION;
long long cnt;
static int S,SUBTASK;
static STATION stations[10004];

int cmp_fun_1(const void *a,const void *b)
{
    STATION c,d;
    c = *(STATION*)(a);
    d = *(STATION*)(b);
    return c.location < d.location ? -1 : 1;
}

int cmp_fun_2(const void *a,const void *b)
{
    STATION c,d;
    c = *(STATION*)(a);
    d = *(STATION*)(b);
    return c.index < d.index ? -1 : 1;
}

void now_I_want_to_getLR(){
    int now = stations[S-1].index,i;
    for(i=S-2;i>=0;i--){
        stations[i].R = now;
        if(stations[i].type==2)	now = stations[i].index;
    }
    now = stations[0].index;
    for(i=1;i<S;i++){
        stations[i].L = now;
        if(stations[i].type==1)	now = stations[i].index;
    }
}

int getDistance(int x,int y)
{
    cnt++;
    if(x==y)	return 0;
    if(x<0 || x>=S || y<0 || y>=S)    return -1;
    if(stations[x].location > stations[y].location){
        int tmp = x;
        x = y;
        y = tmp;
    }
    int ret = 0;
    if(stations[x].type==1 && stations[y].type==1){
        ret = stations[stations[y].R].location-stations[x].location+stations[stations[y].R].location-stations[y].location;
    }else if(stations[x].type==1 && stations[y].type==2){
        ret = stations[y].location-stations[x].location;
    }else if(stations[x].type==2 && stations[y].type==2){
        ret = stations[x].location-stations[stations[x].L].location+stations[y].location-stations[stations[x].L].location;
    }else if(stations[x].type==2 && stations[y].type==1){
        ret = stations[x].location-stations[stations[x].L].location+stations[stations[y].R].location
              -stations[stations[x].L].location+stations[stations[y].R].location-stations[y].location;
    }
    return ret;
}


void getInput()
{
    int g;
    g = scanf("%d",&SUBTASK);
    g = scanf("%d",&S);
    int s;
    for (s = 0; s < S; s++) {
        int type, location;
        g = scanf(" %d %d",&type,&location);
        stations[s].index = s;
        stations[s].location = location;
        stations[s].type = type;
        stations[s].L = -1;
        stations[s].R = -1;
    }
    qsort(stations, S, sizeof(STATION), cmp_fun_1);
    now_I_want_to_getLR();
    qsort(stations, S, sizeof(STATION), cmp_fun_2);
}

int serverGetStationNumber()
{
    return S;
}

int serverGetSubtaskNumber()
{
    return SUBTASK;
}

int serverGetFirstStationLocation()
{
    return stations[0].location;
}

int main()
{
    int i;
    getInput();
    cnt = 0;

    int location[10005];
    int type[10005];
    int ok = 1;
    findLocation(S, serverGetFirstStationLocation(),location, type);
    if(SUBTASK==3 && cnt>S*(S-1))	ok = 0;
    if(SUBTASK==4 && cnt>3*(S-1))	ok = 0;


    for (i = 0; i < S; i++)
        if(type[i]!=stations[i].type || location[i]!=stations[i].location)
            ok = 0;
    if(ok==0)	printf("Incorrect");
    else	printf("Correct");
    return 0;
}*/
/*
3
6
1 5
1 1
2 12
2 2
1 3
2 4
2 6
1 6
2 8
1 9
2 10
1 11
 */

详细

Subtask #1:

score: 8
Accepted

Test #1:

score: 8
Accepted
time: 1ms
memory: 3868kb

input:

1
100
1 11
2 794
2 775
2 347
2 737
2 864
2 584
2 555
2 361
2 429
2 892
2 302
2 483
2 217
2 39
2 566
2 435
2 448
2 304
2 466
2 386
2 780
2 164
2 918
2 601
2 867
2 929
2 341
2 636
2 556
2 954
2 430
2 683
2 301
2 519
2 547
2 237
2 426
2 908
2 667
2 670
2 210
2 502
2 887
2 420
2 675
2 401
2 724
2 493
2 ...

output:

Correct

result:

ok 

Test #2:

score: 8
Accepted
time: 0ms
memory: 3792kb

input:

1
100
1 13
2 768
2 165
2 101
2 185
2 678
2 145
2 865
2 650
2 769
2 985
2 756
2 236
2 973
2 688
2 522
2 654
2 316
2 598
2 901
2 274
2 547
2 744
2 511
2 684
2 331
2 822
2 757
2 198
2 85
2 526
2 363
2 186
2 711
2 393
2 683
2 928
2 43
2 805
2 914
2 152
2 239
2 840
2 916
2 893
2 509
2 514
2 561
2 410
2 7...

output:

Correct

result:

ok 

Test #3:

score: 8
Accepted
time: 1ms
memory: 3688kb

input:

1
100
1 21
2 40
2 217
2 337
2 711
2 392
2 260
2 838
2 625
2 839
2 378
2 468
2 338
2 105
2 663
2 79
2 993
2 811
2 398
2 694
2 742
2 937
2 281
2 131
2 733
2 710
2 520
2 128
2 381
2 912
2 345
2 718
2 623
2 90
2 330
2 983
2 307
2 168
2 608
2 147
2 898
2 428
2 837
2 92
2 268
2 349
2 255
2 667
2 43
2 270
...

output:

Correct

result:

ok 

Test #4:

score: 8
Accepted
time: 0ms
memory: 3872kb

input:

1
100
1 30
2 512
2 723
2 790
2 546
2 811
2 767
2 427
2 761
2 489
2 938
2 287
2 195
2 145
2 231
2 87
2 62
2 691
2 671
2 583
2 268
2 522
2 395
2 632
2 500
2 873
2 863
2 478
2 447
2 904
2 809
2 311
2 627
2 951
2 857
2 718
2 636
2 552
2 560
2 574
2 191
2 755
2 71
2 774
2 194
2 134
2 466
2 866
2 69
2 86
...

output:

Correct

result:

ok 

Test #5:

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

input:

1
100
1 38
2 657
2 545
2 832
2 707
2 992
2 829
2 423
2 985
2 162
2 897
2 335
2 744
2 756
2 352
2 238
2 268
2 677
2 824
2 960
2 733
2 496
2 411
2 63
2 675
2 223
2 745
2 193
2 85
2 885
2 202
2 630
2 717
2 910
2 622
2 898
2 685
2 413
2 934
2 647
2 157
2 690
2 999
2 395
2 310
2 425
2 134
2 323
2 510
2 9...

output:

Correct

result:

ok 

Test #6:

score: 8
Accepted
time: 1ms
memory: 4028kb

input:

1
100
1 12
2 669
2 901
2 133
2 896
2 738
2 776
2 44
2 134
2 154
2 29
2 638
2 937
2 874
2 235
2 397
2 779
2 709
2 588
2 701
2 324
2 965
2 865
2 251
2 710
2 715
2 689
2 249
2 174
2 551
2 270
2 427
2 684
2 518
2 165
2 812
2 914
2 298
2 68
2 899
2 936
2 357
2 773
2 524
2 755
2 552
2 233
2 343
2 605
2 90...

output:

Correct

result:

ok 

Test #7:

score: 8
Accepted
time: 0ms
memory: 4032kb

input:

1
100
1 47
2 198
2 904
2 942
2 714
2 510
2 431
2 594
2 690
2 75
2 449
2 786
2 920
2 277
2 731
2 742
2 136
2 760
2 633
2 224
2 637
2 927
2 959
2 222
2 657
2 474
2 611
2 401
2 307
2 759
2 952
2 563
2 701
2 666
2 425
2 484
2 613
2 115
2 505
2 688
2 564
2 292
2 609
2 194
2 375
2 703
2 330
2 336
2 555
2 ...

output:

Correct

result:

ok 

Test #8:

score: 8
Accepted
time: 1ms
memory: 3948kb

input:

1
100
1 7
2 631
2 253
2 535
2 16
2 311
2 891
2 250
2 698
2 843
2 525
2 43
2 740
2 429
2 610
2 643
2 276
2 529
2 243
2 174
2 229
2 537
2 288
2 685
2 459
2 823
2 878
2 72
2 759
2 663
2 573
2 366
2 294
2 179
2 842
2 144
2 265
2 541
2 340
2 791
2 936
2 432
2 572
2 898
2 75
2 201
2 427
2 670
2 375
2 8
2 ...

output:

Correct

result:

ok 

Test #9:

score: 8
Accepted
time: 0ms
memory: 3788kb

input:

1
100
1 34
2 445
2 537
2 285
2 903
2 312
2 975
2 250
2 885
2 125
2 818
2 557
2 560
2 525
2 400
2 227
2 577
2 50
2 340
2 748
2 390
2 370
2 508
2 663
2 150
2 144
2 923
2 741
2 746
2 909
2 100
2 191
2 446
2 385
2 759
2 713
2 696
2 996
2 838
2 515
2 353
2 747
2 75
2 879
2 499
2 654
2 456
2 550
2 994
2 9...

output:

Correct

result:

ok 

Test #10:

score: 8
Accepted
time: 1ms
memory: 4040kb

input:

1
100
1 31
2 325
2 179
2 190
2 113
2 350
2 720
2 553
2 712
2 465
2 524
2 657
2 671
2 665
2 390
2 348
2 620
2 901
2 342
2 116
2 649
2 724
2 473
2 789
2 618
2 890
2 449
2 334
2 669
2 232
2 363
2 346
2 763
2 554
2 459
2 114
2 626
2 178
2 91
2 889
2 180
2 100
2 912
2 197
2 843
2 260
2 170
2 96
2 954
2 2...

output:

Correct

result:

ok 

Subtask #2:

score: 22
Accepted

Test #11:

score: 22
Accepted
time: 1ms
memory: 3796kb

input:

2
100
1 7327
1 116
2 9993
1 2736
1 6502
1 4106
1 6326
2 8055
1 6767
1 388
2 7645
1 1780
1 6159
2 7738
1 3706
1 3476
2 9549
2 7564
1 2401
1 6353
2 8829
1 945
1 606
1 4664
2 9585
2 7499
1 6703
1 3229
1 1382
2 8286
1 6805
1 351
1 793
1 1641
1 3087
1 3647
1 2099
2 9414
1 1703
2 8866
2 9802
2 9348
1 6999...

output:

Correct

result:

ok 

Test #12:

score: 22
Accepted
time: 0ms
memory: 3848kb

input:

2
100
1 1901
1 411
2 9673
2 2260
2 8712
2 7185
2 5395
1 1269
2 3469
2 2852
2 2413
2 7783
2 5977
1 1813
2 6087
2 8802
2 3390
2 5039
2 2569
2 4694
2 4812
2 5704
1 586
2 9645
2 4978
2 8969
1 1204
2 2191
2 5943
1 689
2 7955
2 9270
2 6567
2 4334
2 3816
2 8314
2 1955
2 7285
1 1166
1 720
1 1420
2 3495
2 25...

output:

Correct

result:

ok 

Test #13:

score: 22
Accepted
time: 0ms
memory: 3732kb

input:

2
100
1 1415
1 437
2 9880
2 3580
2 7655
2 6320
2 2670
2 4305
2 4632
2 7346
2 9814
2 9368
2 5374
2 2260
2 3386
2 4316
2 3357
2 7526
2 7175
2 7817
2 3513
2 4225
2 2655
2 5494
2 8763
2 9731
2 5138
1 1142
2 4612
2 4541
2 5931
1 584
2 9734
2 9511
2 8239
2 2406
2 2182
2 2545
2 7039
2 5880
2 8711
2 6407
1 ...

output:

Correct

result:

ok 

Test #14:

score: 22
Accepted
time: 1ms
memory: 3948kb

input:

2
100
1 2038
1 225
2 9673
2 7337
2 5096
2 4800
2 6802
2 7455
2 4099
2 4191
1 1709
1 1103
2 5684
2 6557
2 2721
2 5856
2 4968
2 7917
1 1993
2 9660
2 5644
1 1917
2 3549
1 1585
2 6539
1 1260
2 7557
1 947
1 1881
2 2710
2 8560
2 2742
2 3714
2 7543
2 6868
2 7464
1 1642
1 1060
2 5525
2 9097
1 1122
1 1210
2 ...

output:

Correct

result:

ok 

Test #15:

score: 22
Accepted
time: 1ms
memory: 3948kb

input:

2
100
1 7252
1 151
2 9808
1 3057
1 4522
1 5639
1 6094
2 9254
2 8858
1 5939
2 8584
1 7218
2 8112
1 4381
1 3678
1 1662
1 1899
1 5713
1 3520
1 4699
2 8353
1 6579
2 9583
2 8042
1 2588
1 4762
1 1522
1 6720
1 4373
1 896
2 7340
1 4376
1 3940
1 4275
2 7433
1 4814
1 6266
1 4068
1 5124
1 5819
1 2652
1 2343
1 ...

output:

Correct

result:

ok 

Test #16:

score: 22
Accepted
time: 1ms
memory: 3948kb

input:

2
100
1 3294
1 357
2 9844
2 9740
2 5435
2 9577
1 864
2 5781
1 851
2 3821
2 4905
2 4712
2 4633
2 9524
2 5642
1 1230
2 7759
2 3568
2 8011
1 3247
2 9641
2 4309
2 9125
1 2458
1 1907
2 9538
2 5194
1 2491
2 3399
2 7903
1 1500
2 9700
2 7643
2 6935
2 5630
2 4860
2 9068
2 6481
2 8681
2 3973
2 7546
2 9666
2 4...

output:

Correct

result:

ok 

Test #17:

score: 22
Accepted
time: 1ms
memory: 3820kb

input:

2
100
1 4873
1 217
2 9694
1 2520
2 5783
2 9383
2 6576
1 1423
2 5313
2 9437
2 5334
1 3222
1 3794
1 1001
2 6338
2 5692
1 1460
1 334
2 6029
1 3147
2 7309
2 6978
2 6554
2 8726
1 1030
1 2838
2 7012
1 2116
2 6742
2 6081
1 275
1 3772
2 4954
2 6058
2 9508
2 7882
1 3834
1 4821
2 7685
1 3271
2 7259
1 3417
2 6...

output:

Correct

result:

ok 

Test #18:

score: 22
Accepted
time: 0ms
memory: 3776kb

input:

2
100
1 2614
1 286
2 9704
1 1272
2 8020
2 9591
2 5027
2 2725
2 3140
1 2235
1 2453
1 1187
2 3012
1 1545
2 4515
2 7054
2 5093
2 8592
1 1445
1 2292
2 3280
2 8146
2 5169
2 6695
1 2267
2 4584
1 1167
2 3103
2 4766
1 689
2 2741
2 4014
2 4434
2 8183
2 9041
2 3512
1 1323
2 7628
2 5965
1 2510
1 640
1 2550
2 4...

output:

Correct

result:

ok 

Test #19:

score: 22
Accepted
time: 1ms
memory: 3948kb

input:

2
100
1 6399
1 178
2 9675
1 3942
1 3328
1 4149
1 3640
1 6214
2 8677
1 2608
1 3755
1 1524
1 5766
1 3158
1 1165
1 4695
2 6866
1 4729
1 529
1 4207
2 6663
2 7778
1 3203
1 614
2 8457
1 5472
1 5182
1 3799
2 9316
1 4361
1 2311
1 4655
2 6460
1 1992
2 8804
1 2135
1 1371
1 5130
1 1095
1 1478
2 6654
2 6862
1 4...

output:

Correct

result:

ok 

Test #20:

score: 22
Accepted
time: 1ms
memory: 4032kb

input:

2
100
1 7653
1 473
2 9622
2 9239
1 4765
1 4086
1 4598
1 736
1 6988
1 5711
1 3386
1 3780
1 6603
1 5591
1 6070
1 6290
1 894
1 1714
1 3094
1 4744
1 6656
1 6707
1 910
1 5948
2 8821
1 7254
1 2407
2 7928
1 1157
1 5232
1 7306
1 7482
1 1219
1 6545
2 8599
1 5305
1 7495
1 5687
2 8645
1 3207
1 5688
2 8383
1 33...

output:

Correct

result:

ok 

Subtask #3:

score: 26
Accepted

Test #21:

score: 26
Accepted
time: 3ms
memory: 4352kb

input:

3
5000
1 763228
1 39310
2 962072
2 203549
1 85439
2 414565
2 78225
1 185073
2 174996
2 386604
1 662313
2 96651
1 271323
2 556033
1 788441
1 717148
1 404737
2 197742
2 760887
1 549658
2 713177
1 156708
1 858133
1 166177
1 809643
2 365041
1 73222
2 706708
2 296516
1 861386
1 782475
2 167675
1 100665
1...

output:

Correct

result:

ok 

Test #22:

score: 26
Accepted
time: 0ms
memory: 4312kb

input:

3
5000
1 636279
1 26189
2 970246
1 307897
2 220915
2 636718
2 483261
2 777502
1 773766
2 965618
2 635178
1 575702
1 316269
1 952647
2 234672
2 902599
1 594364
1 560513
1 602505
1 517138
1 230033
1 546231
1 604628
1 342380
1 338380
2 266507
2 60915
2 525809
2 882043
2 512735
1 598286
1 417391
1 53842...

output:

Correct

result:

ok 

Test #23:

score: 26
Accepted
time: 3ms
memory: 4400kb

input:

3
5000
1 548843
1 3987
2 986637
1 758029
2 77828
1 473460
1 236849
2 107870
1 787772
1 387244
1 8386
1 958871
1 535830
2 451556
1 546735
1 324516
1 915626
2 791473
1 916863
2 441513
2 564992
2 520651
2 377154
1 162400
2 550141
1 829040
1 153367
2 25506
2 83342
1 923369
1 571973
2 233978
2 350689
2 4...

output:

Correct

result:

ok 

Test #24:

score: 26
Accepted
time: 3ms
memory: 4160kb

input:

3
5000
1 531209
1 27812
2 992446
1 659258
2 273026
1 883371
1 752145
2 904967
1 848400
2 474352
1 769016
2 897154
1 89535
1 368711
2 714600
2 648437
2 310903
1 805949
2 623398
1 555654
2 740276
2 853765
1 336201
2 797238
2 915616
2 135698
1 254891
1 906556
1 40491
2 243724
2 946547
1 633228
2 826882...

output:

Correct

result:

ok 

Test #25:

score: 26
Accepted
time: 3ms
memory: 4216kb

input:

3
5000
1 176713
1 8467
2 967251
2 502250
2 819938
1 889253
1 252140
1 884395
1 766273
2 706637
2 706167
2 860405
1 840738
1 404201
1 903958
2 77130
1 780591
1 258906
2 659005
2 510004
2 726854
1 243531
2 414687
2 646246
2 497801
1 858862
1 635036
1 31038
2 467648
1 246914
1 257135
2 72045
1 302790
2...

output:

Correct

result:

ok 

Test #26:

score: 26
Accepted
time: 3ms
memory: 4156kb

input:

3
5000
1 79287
1 36504
2 960953
2 669873
2 109300
1 634411
2 151696
2 960168
1 149006
1 130092
2 922306
2 820947
1 345882
1 626622
1 656681
2 330863
1 335100
1 515143
1 740926
2 837999
1 625555
2 598507
2 671140
1 470710
1 479945
2 429603
1 806382
1 769846
1 912820
2 687989
2 716628
2 566927
1 63829...

output:

Correct

result:

ok 

Test #27:

score: 26
Accepted
time: 3ms
memory: 4096kb

input:

3
5000
1 244532
1 36942
2 968840
2 657394
2 310657
1 919709
1 704692
1 547525
2 811409
2 798171
2 760184
2 904899
2 446284
2 457722
1 291907
1 217562
2 343990
1 110024
1 702106
1 77181
2 889558
1 887274
2 135947
1 818415
1 524721
2 667789
2 40245
2 761674
1 141196
2 317961
2 340650
1 356185
2 294216...

output:

Correct

result:

ok 

Test #28:

score: 26
Accepted
time: 4ms
memory: 4136kb

input:

3
5000
1 527562
1 39187
2 988590
2 828665
1 810736
2 614807
1 528280
1 82573
2 474166
1 875696
2 393989
1 978643
1 921939
1 124764
2 370077
2 719596
2 426558
1 928753
2 273770
1 325879
2 705884
1 351313
1 742125
2 321971
1 479740
2 467474
1 438940
2 136853
1 97674
1 43692
1 696496
2 574767
1 558218
...

output:

Correct

result:

ok 

Test #29:

score: 26
Accepted
time: 3ms
memory: 4396kb

input:

3
5000
1 600657
1 48312
2 991028
1 645814
1 510500
2 947967
1 54903
2 951487
2 743081
1 372129
2 159275
2 844132
2 936267
1 683317
1 599862
1 724743
1 482305
2 256644
1 588574
2 828829
2 900134
1 867044
2 406199
1 679399
1 688006
2 88576
1 521946
2 524459
1 683655
1 629231
1 907107
1 389412
1 298494...

output:

Correct

result:

ok 

Test #30:

score: 26
Accepted
time: 3ms
memory: 4400kb

input:

3
5000
1 363944
1 3137
2 970845
2 501924
2 822408
1 437333
2 908396
2 503014
1 744918
2 588924
2 439592
2 55141
1 703483
2 43930
1 847071
2 701672
1 396645
1 895952
1 639438
2 320030
2 37090
1 57729
1 294424
1 555695
1 76396
2 512296
2 749464
1 662338
2 818423
2 184207
2 221292
1 371193
2 513309
2 4...

output:

Correct

result:

ok 

Subtask #4:

score: 44
Accepted

Test #31:

score: 44
Accepted
time: 3ms
memory: 4152kb

input:

3
5000
1 763228
1 39310
2 962072
2 203549
1 85439
2 414565
2 78225
1 185073
2 174996
2 386604
1 662313
2 96651
1 271323
2 556033
1 788441
1 717148
1 404737
2 197742
2 760887
1 549658
2 713177
1 156708
1 858133
1 166177
1 809643
2 365041
1 73222
2 706708
2 296516
1 861386
1 782475
2 167675
1 100665
1...

output:

Correct

result:

ok 

Test #32:

score: 44
Accepted
time: 4ms
memory: 4096kb

input:

3
5000
1 636279
1 26189
2 970246
1 307897
2 220915
2 636718
2 483261
2 777502
1 773766
2 965618
2 635178
1 575702
1 316269
1 952647
2 234672
2 902599
1 594364
1 560513
1 602505
1 517138
1 230033
1 546231
1 604628
1 342380
1 338380
2 266507
2 60915
2 525809
2 882043
2 512735
1 598286
1 417391
1 53842...

output:

Correct

result:

ok 

Test #33:

score: 44
Accepted
time: 3ms
memory: 4236kb

input:

3
5000
1 548843
1 3987
2 986637
1 758029
2 77828
1 473460
1 236849
2 107870
1 787772
1 387244
1 8386
1 958871
1 535830
2 451556
1 546735
1 324516
1 915626
2 791473
1 916863
2 441513
2 564992
2 520651
2 377154
1 162400
2 550141
1 829040
1 153367
2 25506
2 83342
1 923369
1 571973
2 233978
2 350689
2 4...

output:

Correct

result:

ok 

Test #34:

score: 44
Accepted
time: 3ms
memory: 4400kb

input:

3
5000
1 531209
1 27812
2 992446
1 659258
2 273026
1 883371
1 752145
2 904967
1 848400
2 474352
1 769016
2 897154
1 89535
1 368711
2 714600
2 648437
2 310903
1 805949
2 623398
1 555654
2 740276
2 853765
1 336201
2 797238
2 915616
2 135698
1 254891
1 906556
1 40491
2 243724
2 946547
1 633228
2 826882...

output:

Correct

result:

ok 

Test #35:

score: 44
Accepted
time: 3ms
memory: 4156kb

input:

3
5000
1 176713
1 8467
2 967251
2 502250
2 819938
1 889253
1 252140
1 884395
1 766273
2 706637
2 706167
2 860405
1 840738
1 404201
1 903958
2 77130
1 780591
1 258906
2 659005
2 510004
2 726854
1 243531
2 414687
2 646246
2 497801
1 858862
1 635036
1 31038
2 467648
1 246914
1 257135
2 72045
1 302790
2...

output:

Correct

result:

ok 

Test #36:

score: 44
Accepted
time: 3ms
memory: 4416kb

input:

3
5000
1 79287
1 36504
2 960953
2 669873
2 109300
1 634411
2 151696
2 960168
1 149006
1 130092
2 922306
2 820947
1 345882
1 626622
1 656681
2 330863
1 335100
1 515143
1 740926
2 837999
1 625555
2 598507
2 671140
1 470710
1 479945
2 429603
1 806382
1 769846
1 912820
2 687989
2 716628
2 566927
1 63829...

output:

Correct

result:

ok 

Test #37:

score: 44
Accepted
time: 3ms
memory: 4216kb

input:

3
5000
1 244532
1 36942
2 968840
2 657394
2 310657
1 919709
1 704692
1 547525
2 811409
2 798171
2 760184
2 904899
2 446284
2 457722
1 291907
1 217562
2 343990
1 110024
1 702106
1 77181
2 889558
1 887274
2 135947
1 818415
1 524721
2 667789
2 40245
2 761674
1 141196
2 317961
2 340650
1 356185
2 294216...

output:

Correct

result:

ok 

Test #38:

score: 44
Accepted
time: 3ms
memory: 4100kb

input:

3
5000
1 527562
1 39187
2 988590
2 828665
1 810736
2 614807
1 528280
1 82573
2 474166
1 875696
2 393989
1 978643
1 921939
1 124764
2 370077
2 719596
2 426558
1 928753
2 273770
1 325879
2 705884
1 351313
1 742125
2 321971
1 479740
2 467474
1 438940
2 136853
1 97674
1 43692
1 696496
2 574767
1 558218
...

output:

Correct

result:

ok 

Test #39:

score: 44
Accepted
time: 3ms
memory: 4164kb

input:

3
5000
1 600657
1 48312
2 991028
1 645814
1 510500
2 947967
1 54903
2 951487
2 743081
1 372129
2 159275
2 844132
2 936267
1 683317
1 599862
1 724743
1 482305
2 256644
1 588574
2 828829
2 900134
1 867044
2 406199
1 679399
1 688006
2 88576
1 521946
2 524459
1 683655
1 629231
1 907107
1 389412
1 298494...

output:

Correct

result:

ok 

Test #40:

score: 44
Accepted
time: 3ms
memory: 4236kb

input:

3
5000
1 363944
1 3137
2 970845
2 501924
2 822408
1 437333
2 908396
2 503014
1 744918
2 588924
2 439592
2 55141
1 703483
2 43930
1 847071
2 701672
1 396645
1 895952
1 639438
2 320030
2 37090
1 57729
1 294424
1 555695
1 76396
2 512296
2 749464
1 662338
2 818423
2 184207
2 221292
1 371193
2 513309
2 4...

output:

Correct

result:

ok 

Test #41:

score: 44
Accepted
time: 3ms
memory: 4164kb

input:

4
5000
1 201991
1 26322
2 957101
1 501251
2 414806
2 28545
1 458283
2 905458
1 402253
1 223948
1 168209
1 786332
1 737515
2 232353
1 608639
2 517891
2 513377
1 679213
1 880964
1 577435
1 827371
2 869673
2 541168
2 199626
2 592363
2 528413
2 720169
1 94860
1 301681
2 511599
1 292790
2 381758
1 398261...

output:

Correct

result:

ok 

Test #42:

score: 44
Accepted
time: 3ms
memory: 4104kb

input:

4
5000
1 185089
1 9341
2 972952
1 157793
2 432574
2 853818
2 161900
2 641600
2 297633
1 920450
1 14197
2 562034
1 129523
2 796726
1 592704
2 372849
1 585183
2 409432
1 606335
2 553787
2 864481
1 680423
1 869487
1 143415
2 486257
1 920603
1 279328
1 640310
2 363204
1 391412
2 820079
2 91327
2 583227
...

output:

Correct

result:

ok 

Test #43:

score: 44
Accepted
time: 3ms
memory: 4216kb

input:

4
5000
1 650367
1 42568
2 985107
1 200699
1 900854
1 83166
2 894066
1 771415
2 111087
1 498037
2 267078
2 867355
1 392451
2 760454
1 335549
2 946122
2 566038
1 746369
1 181297
2 73668
2 599040
1 882265
2 266253
1 514247
1 885294
1 277799
1 452725
1 58860
1 492532
2 916597
1 379071
1 575175
2 963750
...

output:

Correct

result:

ok 

Test #44:

score: 44
Accepted
time: 3ms
memory: 4224kb

input:

4
5000
1 776086
1 5262
2 959476
2 116811
2 27877
2 406928
2 424296
2 804189
2 548060
1 530622
1 757280
1 689769
2 356698
2 480529
2 526645
1 522920
2 343864
2 77766
2 282268
2 494354
1 796641
2 714166
1 513334
1 792345
2 871855
1 347030
2 81158
1 751610
2 457254
2 211331
2 490220
1 756404
1 596300
1...

output:

Correct

result:

ok 

Test #45:

score: 44
Accepted
time: 3ms
memory: 4404kb

input:

4
5000
1 454113
1 10488
2 964392
1 860609
2 135751
1 605256
1 182839
1 340299
1 494012
1 112396
1 164725
1 467328
1 431157
2 130813
1 71786
2 577180
2 361524
2 855015
1 305869
2 366331
2 401905
1 277371
1 186273
1 285708
1 879347
1 798508
2 343084
2 147785
1 555309
2 818225
2 850378
2 37974
2 550568...

output:

Correct

result:

ok 

Test #46:

score: 44
Accepted
time: 4ms
memory: 4404kb

input:

4
5000
1 629499
1 7618
2 989580
2 866538
2 466042
2 422720
2 288494
1 461908
1 904404
2 651829
1 908547
2 328731
2 694926
2 433200
2 86715
1 468824
1 757224
1 65692
2 325684
1 658419
1 209096
2 831582
1 214481
2 244623
2 422270
1 976249
1 541685
2 531177
1 964377
2 84907
2 260837
2 643265
1 439519
2...

output:

Correct

result:

ok 

Test #47:

score: 44
Accepted
time: 3ms
memory: 4112kb

input:

4
5000
1 139132
1 24465
2 996845
2 800338
1 601386
2 118542
2 675419
1 925597
1 617282
2 617672
2 933031
1 585856
2 93106
2 960574
1 298667
1 183390
2 221189
2 124077
2 108194
1 944413
1 429195
1 642747
1 418749
2 350732
1 149962
2 555648
1 696228
1 543717
1 232026
2 677599
1 635018
2 801615
1 68519...

output:

Correct

result:

ok 

Test #48:

score: 44
Accepted
time: 3ms
memory: 4100kb

input:

4
5000
1 792367
1 47743
2 999001
2 755834
1 951735
2 375064
1 223728
1 667940
2 239226
2 701238
1 203164
1 58560
2 946815
2 225459
1 638978
1 207904
1 642060
2 540477
1 296311
2 511056
1 84583
2 473650
1 922148
2 254729
1 472716
2 997219
1 886081
1 63754
1 112429
1 921442
1 111818
2 909024
1 89266
1...

output:

Correct

result:

ok 

Test #49:

score: 44
Accepted
time: 1ms
memory: 4360kb

input:

4
5000
1 340199
1 12891
2 979654
1 36012
2 321706
1 702504
2 584921
2 799094
2 660495
1 376365
1 747745
1 968268
1 360313
2 740671
2 244056
1 972517
1 524135
1 241273
1 40653
2 196272
2 804892
1 51610
1 341434
2 274771
1 337454
1 530803
2 926746
1 489520
1 631788
2 683248
1 378779
1 849093
1 129259
...

output:

Correct

result:

ok 

Test #50:

score: 44
Accepted
time: 3ms
memory: 4100kb

input:

4
5000
1 188796
1 3921
2 985322
1 77656
2 711624
2 63481
2 177787
1 431658
1 607421
1 834112
2 285251
2 498689
1 649532
2 577112
2 554463
1 200609
1 224415
2 804793
2 746906
1 167375
1 619717
1 376541
2 481912
2 574402
1 113694
2 784035
2 617886
1 764207
2 693327
1 546933
2 229470
2 965014
2 648825
...

output:

Correct

result:

ok 

Extra Test:

score: 0
Extra Test Passed