QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#322094#8163. 正方形扩展HaccerKat#100 ✓486ms67276kbC++203.1kb2024-02-06 10:58:142024-07-04 03:22:44

Judging History

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

  • [2024-07-04 03:22:44]
  • 评测
  • 测评结果:100
  • 用时:486ms
  • 内存:67276kb
  • [2024-02-06 10:58:14]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
#ifdef DEBUG
#define dbg(x) cout << (#x) << " = " << (x) << "\n";
#else
#define dbg(x)
#endif

const int N = 1000005;
class BIT {
public:
    int bit[N], n;    
    BIT(int n) : n(n) {memset(bit, 0, sizeof(bit));}
    void update(int p, int x) {
        p++;
        for (; p <= n; p += p & (-p)) {
            bit[p] += x;
        }
    }
    
    int query(int p) {
        p++;
        int res = 0;
        for (; p > 0; p -= p & (-p)) {
            res += bit[p];
        }
        
        return res;
    }
};

typedef long long ll;
typedef pair<int, int> pi;
const int inf = 1e9 + 5;
int n, m, k, qq, h = 0, w = 0;
array<int, 3> a[N];
vector<pi> sweep[N];
int d[N][8], cnt[N];
void add(int p, int x) {
    for (int y = -1; y <= 1; y++) {
        d[p][(x + y + 8) % 8] = 1;
    }    
}

void solvedir(int val) {
    BIT bit(w + 1);
    memset(cnt, 0, sizeof(cnt));
    int c = 0;
    for (int x = 0; x < h; x++) {
        int sz = sweep[x].size();
        for (int i = 0; i < sz; i++) {
            auto [y, p] = sweep[x][i];
            if (i != 0) add(p, 6);
            if (i != sz - 1) add(p, 2);
            int z = bit.query(y - 1);
            if (z) add(p, 7 - val);
            if (cnt[y]) add(p, val * 2);
            if (z + cnt[y] < c) add(p, 1 + val);
            dbg(x);
            dbg(y);
            dbg(p);
            dbg(z);
            dbg(c);
            dbg(cnt[y]);
        }
        
        for (int i = 0; i < sz; i++) {
            auto [y, p] = sweep[x][i];
            bit.update(y, 1);
            cnt[y]++, c++;
        }
    }
}

void solve() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        swap(x, y);
        a[i] = {x, y, i};
    }
    
    sort(a, a + n);
    int pre = a[0][0];
    for (int i = 0; i < n; i++) {
        auto &[x, y, p] = a[i];
        if (x != pre) h++;
        pre = x, x = h;
        swap(x, y);
    }
    
    sort(a, a + n);
    pre = a[0][0];
    for (int i = 0; i < n; i++) {
        auto &[x, y, p] = a[i];
        if (x != pre) w++;
        pre = x, x = w;
        swap(x, y);
    }
    
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        auto [x, y, p] = a[i];
        sweep[x].push_back({y, p});
    }
    
    h++, w++;
    for (int i = 0; i < h / 2; i++) {
        swap(sweep[i], sweep[h - i - 1]);
    }
    
    solvedir(0);
    for (int i = 0; i < h / 2; i++) {
        swap(sweep[i], sweep[h - i - 1]);
    }
    
    dbg("SPLIT");
    // for (int i = 0; i < n; i++) {
    //     for (int j = 0; j < 8; j++) {
    //         cout << d[i][j];
    //     }
        
    //     cout << "\n";
    // }
    
    solvedir(2);
    for (int i = 0; i < n; i++) {
        int out = 0;
        for (int j = 0; j < 8; j++) {
            // cout << d[i][j];
            if (!d[i][j]) out = 1;
        }
        
        // cout << "\n";
        cout << out;
    }
    
    cout << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 5
Accepted
time: 0ms
memory: 13900kb

input:

93
-891195274 183636471
-764495798 865415679
-12763013 785052733
-586906564 -783958570
264238694 -707787718
-39911703 487720699
-264359136 -388581638
-274661749 -773822775
-319274230 859262853
457383014 -567613225
557167482 -307328000
6438520 -61727603
-303369172 536527866
137500832 729931239
-96076...

output:

000000000000001101000100000010000110000001101000100011000000010011000000100010000000000000100

result:

ok single line: '000000000000001101000100000010...0011000000100010000000000000100'

Test #2:

score: 5
Accepted
time: 0ms
memory: 14516kb

input:

93
425744596 -763346592
-694476255 -846041072
974561491 774923809
-628833796 346949604
680084251 425847080
-340370645 -207810000
-507694333 -23214930
848231661 -407456661
-742426590 860089268
422689263 -71942145
-72622501 906526495
-516205096 939192043
-332843201 703045092
-316913280 -766629589
-436...

output:

001000000000000100010010000001000001000010000000000000011100000000000000000000000000000000010

result:

ok single line: '001000000000000100010010000001...0000000000000000000000000000010'

Test #3:

score: 5
Accepted
time: 0ms
memory: 13664kb

input:

93
-839155673 739773620
-513632871 -717115304
-352159327 -806231080
-398927042 -798002794
362551880 387670362
-890257785 -762239316
-405639326 -952518048
506086117 350550779
168062313 460961509
623803896 -157407248
500860953 -803039754
628958543 7009497
-305576589 341573086
8013673 -437380094
631159...

output:

100001100000000000010000010010001000000000100000110000010000011000000010000000000110001110000

result:

ok single line: '100001100000000000010000010010...1000000010000000000110001110000'

Test #4:

score: 5
Accepted
time: 0ms
memory: 15372kb

input:

93
-55777784 -492614621
279725346 31489298
-774673860 -371759169
689009185 851586844
674149587 -37332918
744334607 -194648430
-947335446 939307009
85437532 -682836120
-857908486 623773734
-894873991 -108748291
-623894437 873008961
-645132142 923700083
-146158950 701994956
558615865 -870318907
575767...

output:

000100100000010010000000000010010001001000000001000000110010100010001001100000001000000000000

result:

ok single line: '000100100000010010000000000010...0010001001100000001000000000000'

Test #5:

score: 5
Accepted
time: 0ms
memory: 14472kb

input:

93
-713533592 -635454137
-770832883 708430570
-558059121 33170622
-827677587 112798996
-187786603 -539245441
508759084 -131912616
-353711409 -424317105
-511992693 223912502
561181185 55621893
440222322 -963734151
-244337570 828997042
378649757 537398508
928459822 302910613
8314637 -757107323
1801067...

output:

000000000000000010000001001000001100000000001010000100001100010000001000000100010000001100100

result:

ok single line: '000000000000000010000001001000...0000001000000100010000001100100'

Test #6:

score: 5
Accepted
time: 0ms
memory: 14284kb

input:

994
132337322 -248374937
559796267 675748149
-633466450 -282867388
635029297 935624612
-616797346 142752210
-391353093 425376030
515504409 124042066
507942567 -313960412
-521192070 255038684
90980398 -314859839
-96195922 -986991023
617383991 889877827
988360733 156745592
-2091028 -996880211
84679360...

output:

000000000000010000100000000000000000000000000010000000000000000000000000000001000000000100000000000000001000001000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000...

result:

ok single line: '000000000000010000100000000000...0000000000000000001000000000000'

Test #7:

score: 5
Accepted
time: 0ms
memory: 13920kb

input:

994
-492139010 -46669548
-882542984 275467157
-17445150 585190424
-20659660 714857300
-841720033 156484153
-960557373 -671452686
-548289280 -5116964
43623641 806769011
-927401447 -828655757
356469093 -3815548
1341969 565100061
303616682 607278643
-287784294 429697560
618866496 -572314494
158775360 9...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010001000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000001000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000001000000000000000000000'

Test #8:

score: 5
Accepted
time: 0ms
memory: 15580kb

input:

994
-991943642 149709305
617536314 -956007912
551659965 -417294918
239320425 -866155837
-150159419 -230139607
961842983 -860054268
-3278948 94129648
30465251 -660947569
-728872863 -595955430
-698729830 -750571722
691286235 -396789172
-576267739 -369690695
526939053 -558483679
214965740 -903655097
63...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000010000000000000000011000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000001000000000001000000000000000000010000000000...

result:

ok single line: '000000000000000000000000000000...0000001000000000000000000000000'

Test #9:

score: 5
Accepted
time: 2ms
memory: 14024kb

input:

994
-378441321 814776920
-653579269 -808649251
-858046754 -850942195
635182079 50925408
572223710 109332396
667322370 -845880004
-586628398 -623420189
-529720906 -987658525
644688146 -431218952
469801275 -632471828
732133729 -97486180
-301827737 720127213
-222418892 217477782
-960714191 816193498
-4...

output:

000000000000000000000000000000000000000000000000000000010000000000000001000000000000000000000000000000000000000000000000000000000000000000001000000000000000100000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000000000000000...

result:

ok single line: '000000000000000000000000000000...0000001000000000000000000000000'

Test #10:

score: 5
Accepted
time: 2ms
memory: 15200kb

input:

994
42881277 -389747079
-303235012 -6073797
-783523239 -830498296
333505505 -854393816
-846375205 818543885
607580537 379453828
-533787033 -981507466
394476661 -564776947
841880342 -780970409
-618168322 370219284
-46908995 -432324255
-374363729 545078108
-215473580 -731825830
-111920705 -363559676
5...

output:

000000000000000000000000001000000000001000000000000000001000000000000000000000001000000010000000010000000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000001100000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000001000...0000000000000000000000000000000'

Test #11:

score: 5
Accepted
time: 44ms
memory: 21864kb

input:

98000
804654485 -744589770
-390178962 -312567041
264881853 -27746749
46139687 -769193873
-644456233 573561085
-927857093 555049356
-790224658 932644261
37514057 23680949
-779103281 118117640
-790064600 -303534788
-348907291 480151426
703520670 -611052944
-372543914 762722572
684190816 -962335157
691...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000000000000000000000000000'

Test #12:

score: 5
Accepted
time: 44ms
memory: 24724kb

input:

98000
-142537033 126484793
-849399359 -661325010
-839721095 -298797100
-624435193 628377831
105793747 -427252914
124599678 907914904
-799915472 -171898998
-285202012 -470716116
-539486984 438926447
298795968 -961437874
-784645661 -48144879
43931023 -359076166
887584355 401558381
-907961552 -64382875...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000000000000000000000000000'

Test #13:

score: 5
Accepted
time: 52ms
memory: 22216kb

input:

98000
-244720507 -702984313
-312465875 385759510
82827306 -752248507
797979578 181094929
-824200106 -590134708
328689599 -70698588
-943542140 301758529
196851432 -885205721
-932618829 939164518
921098273 -629167679
29740313 -926390238
425409853 -595254890
585276549 137116830
290893228 -34952153
-114...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000000000000000000000000000'

Test #14:

score: 5
Accepted
time: 48ms
memory: 25452kb

input:

98000
520182983 -205371799
577896599 897028924
-404975418 68868800
427787550 851260967
140225011 -794206401
44559478 831583661
660452491 -281553300
-833363315 -469397898
-604819885 -408752163
-418773145 796419534
-719242520 124812576
939078297 983229713
-937756051 -289036237
-731984828 640338913
-26...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000000000000000000000000000'

Test #15:

score: 5
Accepted
time: 49ms
memory: 25112kb

input:

98000
-882511044 -154470099
830933082 -230185106
244669700 387784250
697379098 954838344
-71112753 -514336768
930483099 -50014892
440727179 -805773140
254519670 -449623387
-655915001 -293915908
-244018278 421271996
490817929 127119500
589198456 491991409
-507437303 676768295
484753403 -2648195
-7205...

output:

000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000000000000000000000000000'

Test #16:

score: 5
Accepted
time: 468ms
memory: 66492kb

input:

999666
8754 -802
9837 7259
701 67
8422 1665
-6119 -639
-6104 6642
-6366 8931
2500 2882
5232 7673
3155 -8842
-2641 4333
-2022 3479
-341 4907
9673 5185
6640 -6820
-3562 -8458
8254 5885
6330 -6191
-8264 4113
4076 -4478
5571 -7570
-8846 -3595
-8253 2027
-9706 5515
3737 -3789
-4107 -2978
5827 -1700
6117 ...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000000000000000000000000000'

Test #17:

score: 5
Accepted
time: 486ms
memory: 65492kb

input:

999666
-4210 9110
8072 -2488
-3310 -2141
-2487 -8351
-3113 -1551
-5822 6798
-2082 -9306
-5198 -808
-2509 8374
7652 -7838
8323 -247
6971 8952
415 5912
9617 -6501
-1073 -4766
1400 -1872
1639 -5417
7800 -2643
1135 -9021
5540 -2451
-2821 3768
-3137 -9344
995 9113
5865 -8614
-9116 -5664
-6784 7149
2174 -...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000000000000000000000000000'

Test #18:

score: 5
Accepted
time: 465ms
memory: 67012kb

input:

999666
7017 7587
-9205 -2836
-3329 9854
7764 9690
-154 7277
9715 -5478
128 6368
-4269 116
1768 -7859
-6248 6656
3938 9073
-8521 -8565
-5253 1166
-6913 2817
1691 -4110
-7197 -7828
-7479 8746
3455 -4481
-5324 4062
3115 6388
-5881 5294
4980 6228
3565 1818
-1842 -9144
-7573 -2565
-2966 -89
5767 9771
225...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000000000000000000000000000'

Test #19:

score: 5
Accepted
time: 480ms
memory: 66244kb

input:

999666
819 6794
-2354 4214
-1220 -8718
-2923 -5387
7711 -167
-34 -9371
-2002 6636
1357 7581
-176 6738
-1812 9483
-6562 908
-6127 -8376
-393 3988
-1477 4700
-3477 6920
2970 3287
1009 -3335
-1085 7488
8639 4976
-8197 8285
8208 8452
-2137 -7442
7128 6519
-8551 6382
-4745 799
-3728 -6183
5098 -4291
-902...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000000000000000000000000000'

Test #20:

score: 5
Accepted
time: 466ms
memory: 67276kb

input:

999666
-8444 -2302
-6844 -5839
1533 -7807
-972 -4806
7661 -2583
-886 5534
-374 -5723
6751 2754
-4096 2322
799 6055
1083 1634
3433 8232
9297 1485
5 7732
2989 9106
4091 -3249
9344 -1154
803 -7455
769 3953
9846 -2992
6966 -7144
2929 698
9471 -9367
-3104 -4576
8570 2509
2483 7337
-1270 9369
-9792 5540
8...

output:

000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '000000000000000000000000000000...0000000000000000000000000000000'