QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#56843#3873. TowersJanus29 2816ms222356kbC++9.8kb2022-10-21 17:39:132022-10-21 17:39:14

Judging History

This is the latest submission verdict.

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-21 17:39:14]
  • Judged
  • Verdict: 29
  • Time: 2816ms
  • Memory: 222356kb
  • [2022-10-21 17:39:13]
  • Submitted

answer

#include<bits/stdc++.h>
#define MAXN 1000010
using namespace std;
struct coor{ int x, y, id; };
bool operator < (coor a, coor b){
    if(a.x == b.x) return a.y < b.y;
    return a.x < b.x;
}
bool operator > (coor a, coor b){
    if(a.x == b.x) return a.y > b.y;
    return a.x > b.x;
}
bool operator < (coor a, int b){
    return a.y < b;
}
bool operator > (coor a, int b){
    return a.y > b;
}
int n, nx, ny;
int dx[MAXN], dy[MAXN];
coor tower[MAXN];
namespace debug{
    int vis[500][500];
    bool cmp_by_id(coor a, coor b){ return a.id < b.id; }
    vector<coor> cntx[MAXN], cnty[MAXN];
    int check(int ans[]){
        sort(tower + 1, tower + n + 1, cmp_by_id);
        for(int i = 1; i <= n; i++){
            if(ans[i] == 1){
                cntx[tower[i].x].push_back(tower[i]);
                cnty[tower[i].y].push_back(tower[i]);
            }
        }
        for(int i = 1; i <= nx; i++) if((int)cntx[i].size() > 2) return i;
        for(int i = 1; i <= ny; i++) if((int)cnty[i].size() > 2) return i;
        for(int i = 1; i <= n; i++){
            if(ans[i] == 1) continue;
            if(cnty[tower[i].y].size() == 2){
                int x1 = cnty[tower[i].y][0].x, x2 = cnty[tower[i].y][1].x;
                if(x1 > x2) swap(x1, x2);
                if(x1 < tower[i].x && x2 > tower[i].x) continue;
            }
            if(cntx[tower[i].x].size() == 2){
                int y1 = cntx[tower[i].x][0].y, y2 = cntx[tower[i].x][1].y;
                if(y1 > y2) swap(y1, y2);
                if(y1 < tower[i].y && y2 > tower[i].y) continue;
            }
            return -1;
        }
        return 0;
    }
    void main(int ans[]){
        printf("%d\n",check(ans));
    }
    void print(int ans[]){
        sort(tower + 1, tower + n + 1, cmp_by_id);
        printf("--------------------------\n");
        for(int i = 1; i <= n; i++) printf("%d %d\n",tower[i].x,tower[i].y);
        printf("\n");
        for(int i = 1; i <= n; i++){
            if(ans[i] == 0) vis[tower[i].x][tower[i].y] = 1;
            else vis[tower[i].x][tower[i].y] = 2, printf("%d %d\n",tower[i].x,tower[i].y);
        }
        printf("\n");
        for(int i = 1; i <= nx; i++){
            for(int j = 1; j <= ny; j++) printf("%d ",vis[i][j]);
            printf("\n");
        }
    }
}
namespace baoli{
    vector<coor> cntx[MAXN], cnty[MAXN];
    int ans[20];
    bool check(){
        for(int i = 1; i <= n; i++){
            if(ans[i] == 1) continue;
            if(cnty[tower[i].y].size() == 2){
                int x1 = cnty[tower[i].y][0].x, x2 = cnty[tower[i].y][1].x;
                if(x1 > x2) swap(x1, x2);
                if(x1 < tower[i].x && x2 > tower[i].x) continue;
            }
            if(cntx[tower[i].x].size() == 2){
                int y1 = cntx[tower[i].x][0].y, y2 = cntx[tower[i].x][1].y;
                if(y1 > y2) swap(y1, y2);
                if(y1 < tower[i].y && y2 > tower[i].y) continue;
            }
            return false;
        }
        return true;
    }
    void dfs(int now){
        if(now > n){
            if(check()){
                for(int i = 1; i <= n; i++) printf("%d",ans[i]);
                printf("\n");
                exit(0);
            }
            return ;
        }
        if(cntx[tower[now].x].size() <= 1 && cnty[tower[now].y].size() <= 1){
            cntx[tower[now].x].push_back(tower[now]);
            cnty[tower[now].y].push_back(tower[now]);
            ans[now] = 1; dfs(now + 1); ans[now] = 0;
            cntx[tower[now].x].pop_back();
            cnty[tower[now].y].pop_back();
        }
        dfs(now + 1);
    }
    void main(){
        dfs(1);
    }
}
namespace sp1{
    int cntx[MAXN], miny[MAXN], maxy[MAXN], ans[MAXN];
    bool check_sp1(){
        for(int i = 1; i <= n; i++) cntx[tower[i].x]++;
        for(int i = 1; i <= nx; i++) if(cntx[i] > 2) return false;
        return true;
    }
    void main(){
        for(int i = 1; i <= n; i++) if(miny[tower[i].y] == 0 || tower[miny[tower[i].y]].x > tower[i].x) miny[tower[i].y] = i;
        for(int i = 1; i <= n; i++) if(maxy[tower[i].y] == 0 || tower[maxy[tower[i].y]].x < tower[i].x) maxy[tower[i].y] = i;
        for(int i = 1; i <= ny; i++){
            if(miny[i] != 0) ans[miny[i]] = 1;
            if(maxy[i] != 0) ans[maxy[i]] = 1;
        }
        for(int i = 1; i <= n; i++) printf("%d",ans[i]);
        printf("\n");
    }
}
namespace gouzao{
    vector<coor> tx[MAXN]; // x 坐标为 i 的塔的集合
    int idx[MAXN]; // x 坐标为 i 时所选择的 y 坐标较小的塔
    int ans[MAXN], res[MAXN];
    void from_r_to_l(int op){
        priority_queue<int> cy[MAXN]; // y 坐标为 i 时已选择的塔的 x 坐标的集合
        for(int i = 1; i <= n; i++) if(ans[tower[i].id]) cy[tower[i].y].push(tower[i].x);
        for(int i = 1; i <= nx; i++) idx[i] = tx[i].size() - 1;
        for(int i = ny; i >= 1; i--){
            if(cy[i].empty()) continue;
            idx[cy[i].top()]--; cy[i].pop();
            while(cy[i].size() > 1){
                int now = cy[i].top(); cy[i].pop();
                // while(idx[now] >= 0 && tx[now][idx[now]].y != i) idx[now]--;
                idx[now] = lower_bound(tx[now].begin(), tx[now].begin() + idx[now] + 1, i) - tx[now].begin();
                if(idx[now] - op < 0) continue;
                if(ans[tx[now][idx[now]].id] == 0) continue;
                ans[tx[now][idx[now]].id] = 0; idx[now]--;
                if(idx[now] >= 0 && ans[tx[now][idx[now]].id] == 0){
                    cy[tx[now][idx[now]].y].push(now);
                    ans[tx[now][idx[now]].id] = 1;
                }
            }
            if(!cy[i].empty()){
                idx[cy[i].top()]--;
                cy[i].pop();
            }
        }
    }
    void from_l_to_r(int op){
        priority_queue<int> cy[MAXN]; // y 坐标为 i 时已选择的塔的 x 坐标的集合
        for(int i = 1; i <= n; i++) if(ans[tower[i].id]) cy[tower[i].y].push(tower[i].x);
        for(int i = 1; i <= nx; i++) idx[i] = 0;
        for(int i = 1; i <= ny; i++){
            if(cy[i].empty()) continue;
            cy[i].pop();
            while(cy[i].size() > 1){
                int now = cy[i].top(); cy[i].pop();
                // while(idx[now] < (int)tx[now].size() && tx[now][idx[now]].y != i) idx[now]++;
                idx[now] = lower_bound(tx[now].begin(), tx[now].begin() + idx[now] + 1, i) - tx[now].begin();
                if(idx[now] + op >= (int)tx[now].size()) continue;
                if(ans[tx[now][idx[now]].id] == 0) continue;
                ans[tx[now][idx[now]].id] = 0; idx[now]++;
                if(idx[now] < (int)tx[now].size() && ans[tx[now][idx[now]].id] == 0){
                    cy[tx[now][idx[now]].y].push(now);
                    ans[tx[now][idx[now]].id] = 1;
                }
            }
        }
    }
    void radix_sort(int n, coor a[]){
        coor *b = new coor[n];
        int *cnt = new int[1 << 16];
        int mask = (1 << 16) - 1;
        coor *x = a, *y = b;
        for(int i = 0; i < 32; i += 16){
            for(int j = 0; j < (1 << 16); j++) cnt[j] = 0;
            for(int j = 0; j < n; j++) ++cnt[x[j].y >> i & mask];
            for(int sum = 0, j = 0; j < (1 << 16); j++){
                sum += cnt[j]; cnt[j] = sum - cnt[j];
            }
            for(int j = 0; j < n; j++) y[cnt[x[j].y >> i & mask]++] = x[j];
            swap(x, y);
        }
        for(int i = 0; i < 32; i += 16){
            for(int j = 0; j < (1 << 16); j++) cnt[j] = 0;
            for(int j = 0; j < n; j++) ++cnt[x[j].x >> i & mask];
            for(int sum = 0, j = 0; j < (1 << 16); j++){
                sum += cnt[j]; cnt[j] = sum - cnt[j];
            }
            for(int j = 0; j < n; j++) y[cnt[x[j].x >> i & mask]++] = x[j];
            swap(x, y);
        }
        delete[] cnt; delete[] b;
    }
    void main(){
        // sort(tower + 1, tower + n + 1);
        radix_sort(n, tower + 1);
        for(int i = 1; i <= n; i++) tx[tower[i].x].push_back(tower[i]);
        for(int i = 1; i <= nx; i++){
            if(idx[i] < (int)tx[i].size()){
                ans[tx[i][0].id] = 1;
                ans[tx[i].back().id] = 1;
            }
        }
        for(int i = 1; i <= 4; i++){
            from_l_to_r(1);
            from_r_to_l(1);
        }
        from_l_to_r(0);

        for(int i = 1; i <= n; i++) printf("%d",ans[i]);
        printf("\n");
    }
}
void radix_sort(int n, int a[]){
    int *b = new int[n];
    int *cnt = new int[1 << 8];
    int mask = (1 << 8) - 1;
    int *x = a, *y = b;
    for(int i = 0; i < 32; i += 8){
        for(int j = 0; j < (1 << 8); j++) cnt[j] = 0;
        for(int j = 0; j < n; j++) ++cnt[x[j] >> i & mask];
        for(int sum = 0, j = 0; j < (1 << 8); j++){
            sum += cnt[j]; cnt[j] = sum - cnt[j];
        }
        for(int j = 0; j < n; j++) y[cnt[x[j] >> i & mask]++] = x[j];
        swap(x, y);
    }
    delete[] cnt;
    delete[] b;
}
int main(){
    // freopen("data.in", "r", stdin);
    // freopen("my.out", "w", stdout);
    // freopen("tower4.in", "r", stdin);
    // freopen("tower.out", "w", stdout);
    scanf("%d",&n);
    for(int i = 1; i <= n; i++) scanf("%d%d",&tower[i].y,&tower[i].x), tower[i].id = i;
    for(int i = 1; i <= n; i++) dx[i] = tower[i].x, dy[i] = tower[i].y;
    // sort(dx + 1, dx + n + 1); sort(dy + 1, dy + n + 1);
    radix_sort(n, dx + 1); radix_sort(n, dy + 1);
    nx = unique(dx + 1, dx + n + 1) - dx - 1;
    ny = unique(dy + 1, dy + n + 1) - dy - 1;
    for(int i = 1; i <= n; i++) tower[i].x = lower_bound(dx + 1, dx + nx + 1, tower[i].x) - dx;
    for(int i = 1; i <= n; i++) tower[i].y = lower_bound(dy + 1, dy + ny + 1, tower[i].y) - dy;
    gouzao::main();
    return 0;
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 61ms
memory: 152296kb

input:

2
869400 218695
664808 31410

output:

11

result:

ok 

Test #2:

score: 0
Accepted
time: 69ms
memory: 152316kb

input:

2
195447 154323
271823 133730

output:

11

result:

ok 

Test #3:

score: 0
Accepted
time: 56ms
memory: 152232kb

input:

3
751594 545975
951568 859051
621150 686048

output:

111

result:

ok 

Test #4:

score: 0
Accepted
time: 64ms
memory: 152304kb

input:

3
404592 259430
770816 43371
147329 582162

output:

111

result:

ok 

Test #5:

score: 0
Accepted
time: 77ms
memory: 152172kb

input:

3
401670 296316
401670 809250
401670 595959

output:

110

result:

ok 

Test #6:

score: 0
Accepted
time: 64ms
memory: 152168kb

input:

3
657802 927690
657802 872623
657802 83083

output:

101

result:

ok 

Test #7:

score: 0
Accepted
time: 48ms
memory: 152284kb

input:

3
759291 185618
759291 386687
759291 100713

output:

011

result:

ok 

Test #8:

score: 0
Accepted
time: 60ms
memory: 152292kb

input:

3
997737 106763
684497 106763
412296 106763

output:

101

result:

ok 

Test #9:

score: 0
Accepted
time: 72ms
memory: 152288kb

input:

3
305388 642835
538743 642835
608034 642835

output:

101

result:

ok 

Test #10:

score: 0
Accepted
time: 63ms
memory: 152232kb

input:

3
420692 202248
784725 202248
931773 202248

output:

101

result:

ok 

Subtask #2:

score: 11
Accepted

Dependency #1:

100%
Accepted

Test #11:

score: 11
Accepted
time: 55ms
memory: 152304kb

input:

16
296455 404592
582162 770816
807435 536085
259430 536085
112538 770816
610915 369095
582162 369095
94860 147329
112538 147329
296455 61932
259430 147329
807435 369095
610915 404592
807435 309191
807435 61932
94860 770816

output:

1111011101101011

result:

ok 

Test #12:

score: 0
Accepted
time: 69ms
memory: 152288kb

input:

16
561476 595959
58474 595959
58474 664431
105001 143086
809250 250085
58474 250085
789588 281386
350332 161786
789588 250085
561476 281386
296316 401670
296316 250085
350332 595959
296316 161786
350332 281386
58474 281386

output:

1011111101101100

result:

ok 

Test #13:

score: 0
Accepted
time: 69ms
memory: 152316kb

input:

16
316904 170612
433799 125553
316904 125553
859728 341680
433799 32398
872623 388831
859728 83083
872623 83083
584763 388831
148042 861814
316904 861814
927690 861814
148042 83083
148042 32398
584763 657802
905375 388831

output:

1111101111010111

result:

ok 

Test #14:

score: 0
Accepted
time: 47ms
memory: 152296kb

input:

16
386687 759291
995919 169567
788489 197826
185618 713079
198743 100713
995919 372561
916765 169567
185618 763504
386687 169567
832084 763504
832084 759291
386687 292594
185618 197826
386687 197826
832084 197826
916765 759291

output:

1100110111001011

result:

ok 

Test #15:

score: 0
Accepted
time: 85ms
memory: 152228kb

input:

16
716236 20497
587980 648488
587980 642779
412708 997737
369271 642779
106763 71182
412708 642779
173374 869560
684497 648488
587980 945118
106763 648488
716236 412296
587980 71182
412708 869560
369271 869560
412708 412296

output:

1001110111111011

result:

ok 

Test #16:

score: 0
Accepted
time: 52ms
memory: 152300kb

input:

16
642835 173421
512014 309394
610395 518804
538743 305388
493101 608034
610395 85927
214511 309394
512014 173421
214511 608034
493101 85927
512014 85927
538743 309394
538743 608034
512014 518804
610395 309394
214511 518804

output:

1011011111001100

result:

ok 

Test #17:

score: 0
Accepted
time: 75ms
memory: 152224kb

input:

16
327159 848430
202248 689260
248917 848430
860732 109812
810547 931773
248917 551698
248917 109812
327159 109812
202248 420692
784725 848430
810547 109812
860732 551698
860732 848430
784725 109812
810547 689260
810547 551698

output:

0111101010001001

result:

ok 

Test #18:

score: 0
Accepted
time: 60ms
memory: 152156kb

input:

16
929868 357006
544399 533307
65980 485996
679846 756501
679846 533307
679846 712386
888311 756501
679846 357006
569069 357006
679846 326645
65980 712386
569069 756501
544399 357006
929868 712386
929868 326645
888311 357006

output:

0110101001111111

result:

ok 

Test #19:

score: 0
Accepted
time: 61ms
memory: 152332kb

input:

16
819172 856879
310900 856879
110339 25925
110339 712188
110339 856879
193758 568642
110339 518110
334829 712188
819172 25925
334829 518110
962527 856879
962527 712188
819172 568642
193758 712188
819172 518110
193758 856879

output:

0010110011111100

result:

ok 

Test #20:

score: 0
Accepted
time: 61ms
memory: 152284kb

input:

16
788180 40074
788180 353457
642341 40074
919317 353457
642341 341228
139346 808233
788180 889183
919317 40074
87340 808233
788180 341228
139346 32374
919317 808233
919317 341228
753883 32374
87340 32374
919317 32374

output:

1010101010010011

result:

ok 

Test #21:

score: 0
Accepted
time: 66ms
memory: 152236kb

input:

16
965515 596717
798876 887533
800289 573487
798876 325675
798876 596717
965515 760793
800289 887533
800289 760793
798876 573487
965515 887533
681117 596717
965515 573487
48193 325675
965515 325675
798876 760793
681117 325675

output:

0110000111101100

result:

ok 

Test #22:

score: 0
Accepted
time: 55ms
memory: 152164kb

input:

16
149212 434288
500896 813986
149212 874409
149212 399513
820463 813986
468173 874409
500781 461669
820463 461669
149212 461669
820463 434288
468173 399513
500896 434288
468173 461669
820463 874409
500896 874409
149212 813986

output:

0111001001111100

result:

ok 

Test #23:

score: 0
Accepted
time: 55ms
memory: 152316kb

input:

16
699564 798118
908277 529562
699564 529562
522034 155145
699564 882739
699564 676309
522034 882739
674634 882739
908277 882739
908277 155145
674634 529562
269930 529562
674634 676309
269930 882739
269930 798118
269930 676309

output:

1011000011011100

result:

ok 

Test #24:

score: 0
Accepted
time: 64ms
memory: 152224kb

input:

16
340926 122845
837654 479692
340926 665346
933317 122845
355500 820776
914026 479692
933317 665346
837654 665346
914026 665346
933317 900289
837654 820776
914026 900289
837654 900289
340926 900289
340926 820776
933317 479692

output:

1101110011100100

result:

ok 

Test #25:

score: 0
Accepted
time: 53ms
memory: 152312kb

input:

16
778218 780821
275288 780821
624040 780821
639375 399191
639375 88034
624040 775928
639375 655766
778218 775928
478222 399191
639375 780821
478222 775928
275288 655766
275288 88034
624040 655766
478222 88034
778218 399191

output:

1100111010101101

result:

ok 

Subtask #3:

score: 7
Accepted

Test #26:

score: 7
Accepted
time: 128ms
memory: 156672kb

input:

92690
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 6...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 

Test #27:

score: 0
Accepted
time: 127ms
memory: 157288kb

input:

111890
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 

Test #28:

score: 0
Accepted
time: 130ms
memory: 163336kb

input:

339624
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
2...

output:

100000000000000000000000000000000000000000000000000010100000000000000000000000000000000000000000000000001000100000000000000000000000000000000000000000000000100000100000000000000000000000000000000000000000000010000000100000000000000000000000000000000000000000001000000000100000000000000000000000000000...

result:

ok 

Test #29:

score: 0
Accepted
time: 265ms
memory: 175580kb

input:

668528
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 

Test #30:

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

input:

121950
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010...

result:

ok 

Test #31:

score: 0
Accepted
time: 67ms
memory: 153392kb

input:

24628
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 6...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000101000000000000000000000000000000000000...

result:

ok 

Test #32:

score: 0
Accepted
time: 494ms
memory: 177780kb

input:

627882
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 

Test #33:

score: 0
Accepted
time: 207ms
memory: 168032kb

input:

418363
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 

Test #34:

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

input:

934738
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 

Test #35:

score: 0
Accepted
time: 630ms
memory: 184224kb

input:

787195
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 

Test #36:

score: 0
Accepted
time: 409ms
memory: 189096kb

input:

1000000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 

Test #37:

score: 0
Accepted
time: 430ms
memory: 189056kb

input:

998001
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59
1 60
1 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok 

Subtask #4:

score: 6
Accepted

Test #38:

score: 6
Accepted
time: 609ms
memory: 194124kb

input:

1000000
1 18543
4 40327
7 19084
8 44274
10 42366
12 22173
13 9862
15 44706
19 48070
21 13389
24 39273
26 18680
27 46858
28 46126
32 27753
34 28289
36 12220
38 39235
42 28505
45 47348
46 34220
48 47551
50 49156
54 8856
55 25515
56 21932
58 24482
59 20686
61 41381
66 30112
67 44504
70 24510
71 26418
7...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #39:

score: 0
Accepted
time: 652ms
memory: 194116kb

input:

1000000
2 21155
4 41232
6 20287
7 46837
9 38631
11 6901
15 43358
16 10142
19 28642
20 33035
21 27599
24 20951
27 12983
30 11366
31 20539
32 10621
34 30734
37 6043
41 5841
43 8213
46 8479
47 12328
49 5893
50 22485
51 39760
52 8737
54 43535
56 24827
57 15847
59 8402
61 23013
65 17937
66 18072
69 36863...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111111111111111110...

result:

ok 

Test #40:

score: 0
Accepted
time: 598ms
memory: 194100kb

input:

1000000
1 44308
3 27877
4 48227
6 27660
8 26210
9 43909
10 11659
11 34110
13 39632
15 7390
17 40561
20 7928
24 24624
25 9113
27 28937
29 23508
30 41645
32 38110
34 10958
36 37937
37 46339
38 41683
40 7125
41 11569
42 9531
44 29591
45 45867
46 48643
49 7654
50 33740
52 26995
55 13345
57 22001
59 1247...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #41:

score: 0
Accepted
time: 617ms
memory: 193992kb

input:

1000000
2 31149
4 25209
7 47632
9 13365
10 23457
12 38193
14 6534
15 33175
16 12181
19 26329
21 7294
24 25786
26 39155
27 12081
29 31350
33 16989
36 34867
38 31751
39 38661
41 17345
44 24470
47 41098
48 41797
51 27139
53 40756
54 15934
59 28395
63 46853
64 46994
66 14330
67 46212
69 23352
70 8115
72...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #42:

score: 0
Accepted
time: 598ms
memory: 194076kb

input:

1000000
1 38450
2 25296
5 6604
7 5068
8 44733
10 49030
11 48217
12 11533
14 7208
15 37097
16 13793
21 41955
23 45683
25 31223
27 27252
28 26319
30 9053
35 41698
36 18276
41 20100
42 32537
44 41677
46 37754
48 28572
50 44106
52 43957
56 21750
57 21732
61 12737
64 45597
66 42872
67 9711
68 25897
69 41...

output:

111111111111111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111111111111111111111111111111...

result:

ok 

Test #43:

score: 0
Accepted
time: 2781ms
memory: 222356kb

input:

1000000
2 880200
3 405629
4 505753
8 827569
9 249542
15 230517
19 801043
21 393006
23 167265
25 246534
28 302737
32 665950
33 146821
35 765079
36 349562
37 691530
39 446351
40 692089
42 997833
43 688018
44 185484
46 236680
48 414992
50 677116
52 922426
55 930670
57 429844
58 978728
60 671339
62 2508...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #44:

score: 0
Accepted
time: 2757ms
memory: 222180kb

input:

1000000
1 905626
2 338678
5 553579
7 552200
8 784328
10 112106
11 928788
12 719285
14 737963
16 204427
17 313941
19 504387
21 61669
22 430904
24 75978
25 248640
26 317625
29 619690
31 193568
32 966216
34 851031
36 964644
37 111735
38 50038
39 436056
41 165749
42 733480
44 45671
46 501053
47 394829
5...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #45:

score: 0
Accepted
time: 2776ms
memory: 222280kb

input:

1000000
1 524431
7 627962
11 814078
12 347856
14 929279
16 407341
19 77713
22 938040
25 611644
26 421438
27 39608
29 875594
31 950490
33 938280
35 569458
36 399569
37 565433
39 200899
41 512932
42 892335
45 785082
49 138075
52 556802
55 964794
56 23280
59 765396
63 56095
65 334489
67 116493
68 64798...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #46:

score: 0
Accepted
time: 2791ms
memory: 222328kb

input:

1000000
2 793441
5 57521
6 977344
8 152182
9 474068
10 56149
12 388264
15 295964
16 404775
18 333353
19 544761
21 208229
22 409823
26 71607
27 49633
30 748788
32 202839
35 362645
37 896518
38 500521
40 561975
41 682139
42 328620
44 733819
45 687203
47 184074
50 496029
52 831999
53 302832
54 228451
5...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #47:

score: 0
Accepted
time: 2816ms
memory: 222356kb

input:

1000000
1 895838
2 325421
3 954723
4 164307
6 340013
7 825549
10 3829
14 523251
15 52480
17 752743
19 256730
21 743287
24 342268
25 348119
27 164916
28 961505
31 446402
33 903443
37 867901
39 765398
40 319469
41 495869
43 425064
45 442601
48 826731
51 870551
53 419326
54 456719
57 200828
59 642520
6...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Subtask #5:

score: 0
Wrong Answer

Dependency #2:

100%
Accepted

Test #48:

score: 31
Accepted
time: 62ms
memory: 152768kb

input:

5000
630 834940
1078 467873
1422 66913
1625 637429
1858 7094
2604 14606
2856 736849
3081 499898
3119 554225
3576 425440
4849 908007
4853 104538
5110 977236
5143 964159
5747 640988
6165 361056
6365 647136
6927 363570
7593 417679
7633 166611
7868 239524
7922 119686
8093 769337
8323 289956
8562 213370
...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #49:

score: 0
Accepted
time: 69ms
memory: 152612kb

input:

5000
206 486676
260 940061
332 373083
417 29815
1123 924826
1271 128160
1361 962093
1678 199894
2006 703883
2178 328224
2298 567105
2299 392376
2391 567115
2506 878188
2959 121221
3121 792812
3293 658936
3303 416738
3526 319765
3532 385020
3588 867772
3744 5609
3766 726252
3986 312153
4412 248563
44...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 

Test #50:

score: -31
Wrong Answer
time: 56ms
memory: 152564kb

input:

5000
56836 502298
22747 398101
22747 668280
22747 91147
156689 608116
156689 178657
156689 874003
199075 534371
199075 485132
670696 485192
670696 512351
670696 675493
670696 991173
479397 663643
479397 295839
479397 249249
479397 954296
138744 878381
138744 437755
138744 614568
138744 848568
138744...

output:

001110111100001010101000000101100010010110010100001101011101001101010001001100100101010001010000110000001001000011001101100100101000101000101100010000001011101000100010000100000001100011000101101011001000000100101100000010000100001000100100100110010010111100010110010110001000111000100000100101001000...

result:

wrong answer 

Subtask #6:

score: 0
Skipped

Dependency #5:

0%

Subtask #7:

score: 0
Wrong Answer

Test #85:

score: 19
Accepted
time: 2558ms
memory: 219320kb

input:

1000000
1 602300
1 778881
2 397065
3 291452
3 678039
5 235300
6 499367
8 8597
10 327718
10 516489
12 416542
12 440048
13 284169
13 383581
13 642202
13 770858
14 378154
14 710033
15 905531
16 50155
17 142259
19 395613
19 500321
20 358934
21 461772
24 562953
24 995887
25 421244
27 900412
29 301006
31 ...

output:

111111111111100111111111111111101111110111101101111111111111111111111111111111111101111110111111111111110011111011111111111111111111111001111011111001100111101111111111000111111111111111000111111111101111111011111111111111110111111111111111111101111111110111111111011111111111111111111111110110011111...

result:

ok 

Test #86:

score: 0
Accepted
time: 2711ms
memory: 219304kb

input:

1000000
2 58226
2 455245
2 648131
3 483466
4 524911
5 587684
5 697266
6 997653
7 683510
9 770652
10 265650
10 324702
10 391848
10 401829
11 540731
12 827491
14 955978
15 122678
15 331809
16 127204
17 287507
18 116880
18 855160
19 608488
20 395997
21 149717
21 216614
24 24047
24 605282
26 959819
27 6...

output:

101111111110011111111111111111111111111111111111111111111111111111100111111111001111100110111110111111011101110011111111000110111111111111111011111111111111111111111111111111110111111110011111111111110111111111111111111000111101111101111111011111111110011111001101111011111000110110111111111111101111...

result:

ok 

Test #87:

score: 0
Accepted
time: 2581ms
memory: 219316kb

input:

1000000
5 949597
7 311192
7 694097
8 285857
11 104415
12 990158
13 309094
13 419142
13 756795
13 814729
14 478920
15 530506
15 571944
18 570444
20 298039
24 398050
31 309151
32 372683
33 232666
36 956153
38 60556
40 185040
42 733818
45 153225
46 377778
47 55838
51 92225
52 934980
53 552404
57 242988...

output:

111111100111111111111111111111111111111011111110111111111111111101111111111111111110011111111111111111111111111111110111111111111111111011101111111001110011011111111111111111111111111111111111111111111110110111111111011111111111111110001111111111101111001111111111111111111101111111011111101110111101...

result:

ok 

Test #88:

score: -19
Wrong Answer
time: 750ms
memory: 197432kb

input:

1000000
650301 76103
650301 322034
650301 690214
650301 141011
650301 593402
650301 693066
650301 257404
650301 125397
650301 230197
650301 136891
650301 43005
948323 628713
948323 264598
948323 602730
948323 943592
948323 763299
948323 185927
948323 351367
948323 346479
948323 929518
948323 375347
...

output:

001000010000000010000000010001100000010100000010011001000011000000100000000000010001010000000011000000001000001000000001000010000100000100001100000000000001000000010001000001000010000001000000001000000001010000001010000100000000010110000000000001001000000100000100010000100110000100100000011000000000...

result:

wrong answer