QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#75342#5242. Płótno [B]notrealaccount0 0ms0kbC++176.6kb2023-02-04 21:21:452023-02-04 21:21:47

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-04 21:21:47]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2023-02-04 21:21:45]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define fors(u, n, s) for(ll u=(s); u < (n); u++)
#define foru(u, n) fors(u, n, 0)
#define ir(a, b, x) (((a) <= (x)) && ((x) <= (b)))
#define vec vector
#define pb push_back

using namespace std;

int n;
#define K 21
#define N 10000
#define M 4000000

struct seg{
    int a;
    int b;

    bool operator<=(const seg rhs) const{
        return rhs.a<=a && rhs.b>=b;
    }

    bool operator>=(const seg rhs) const{
        return a<=rhs.a && rhs.b<=b;
    }

    bool operator==(const seg rhs) const{
        return ir(a, b, rhs.a) || ir(rhs.a, rhs.b, a);
    }

    bool operator!=(const seg rhs) const{
        return !(ir(a, b, rhs.a) || ir(rhs.a, rhs.b, a));
    }

    int to_int(){
        return b-a+1;
    }

    seg halfA(){
        int m=(a+b)/2;
        seg out;
        out.a=a;
        out.b=m;
        return out;
    }

    seg halfB(){
        int m=(a+b)/2;
        seg out;
        out.a=m+1;
        out.b=b;
        return out;
    }

    seg operator*(const seg rhs) const{
        seg out;
        out.a=max(a, rhs.a);
        out.b=min(b, rhs.b);
        return out;
    }

    bool valid(){
        return a<=b;
    }
};

seg make_seg(int a, int b){
    seg out;
    out.a=a;
    out.b=b;
    return out;
}

int a[N];
int b[N];

struct rect{
    seg x;
    seg y;

    bool valid(){
        return x.valid() && y.valid();
    }

    rect operator*(const rect rhs) const{
        rect out;
        out.x=x*(rhs.x);
        out.y=y*(rhs.y);
        return out;
    }

    bool operator==(const rect rhs) const{
        return x.a==rhs.x.a && x.b==rhs.x.b && y.a==rhs.y.a && y.b==rhs.y.b;
    }

    int to_int(){
        return x.to_int()*y.to_int();
    }

    pair<rect, rect> split(){
        if(x.to_int()!=1){
            pair<rect, rect> output;
            output.first.x=x.halfA();
            output.first.y=y;

            output.second.x=x.halfB();
            output.second.y=y;
            return output;
        }else{
            pair<rect, rect> output;
            output.first.x=x;
            output.first.y=y.halfA();

            output.second.x=x;
            output.second.y=y.halfB();
            return output;
        }
    }
};

rect make_rect(seg x, seg y){
    rect output;
    output.x=x;
    output.y=y;
    return output;
}

vec<rect> rectangles;

void add_edge(int A, int B, int C, int D){
    /// A C
    /// B D
        /// A i B' i C'
        {seg l = make_seg(1, A);
        seg r = make_seg(A, 2*n);

        seg b_seg;
        if(B<A) b_seg=make_seg(B+1, 2*n);
        else b_seg=make_seg(1, B-1);

        seg c_seg;
        if(C<A) c_seg=make_seg(C+1, 2*n);
        else c_seg=make_seg(1, C-1);

        //add(tree, l*b_seg*c_seg, r*b_seg*c_seg, 1);
        seg x = l*b_seg*c_seg; seg y = r*b_seg*c_seg;
        rectangles.pb(make_rect(x, y));
        }

        /// B i A' i D'
        {seg l = make_seg(1, B);
        seg r = make_seg(B, 2*n);

        seg a_seg;
        if(A<B) a_seg=make_seg(A+1, 2*n);
        else a_seg=make_seg(1, A-1);

        seg d_seg;
        if(D<B) d_seg=make_seg(D+1, 2*n);
        else d_seg=make_seg(1, D-1);

        //add(tree, l*a_seg*d_seg, r*a_seg*d_seg, 1);
        seg x = l*a_seg*d_seg; seg y = r*a_seg*d_seg;
        rectangles.pb(make_rect(x, y));

        }

        /// A i B i C' i D'
        {seg l = make_seg(1, A) * make_seg(1, B);
        seg r = make_seg(A, 2*n) * make_seg(B, 2*n);

        bool valid=true;

        seg c_seg;
        if(C<min(A, B)) c_seg=make_seg(C+1, 2*n);
        else if(C>max(A, B)) c_seg=make_seg(1, C-1);
        else valid=false;

        seg d_seg;
        if(D<min(A, B)) d_seg=make_seg(D+1, 2*n);
        else if(D>max(A, B)) d_seg=make_seg(1 , D-1);
        else valid=false;



        if(valid&&(l*c_seg*d_seg).valid()&&(r*c_seg*d_seg).valid()) {
                //add(tree, l*c_seg*d_seg, r*c_seg*d_seg, 1);
                seg x = l*c_seg*d_seg; seg y = r*c_seg*d_seg;
                rectangles.pb(make_rect(x, y));
            }
        }
}



vec<int> process(vec<rect>* rects, rect range){
    if(range.to_int()==1 || rects->size()==0){
        if(rects->size()!=0) cout << "PANIK" << endl;
        vec<int> output;
        foru(i, K) output.pb(0);
        output[0]=range.to_int();
        //cout << "range " << range.x.a << " " <<range.x.b << ", " << range.y.a << " " << range.y.b << endl;
        //foru(i, K) cout << output[i] << " "; cout << endl;
        return output;
    }

    pair<rect, rect> divide = range.split();
    int val[2]; val[0]=0; val[1]=0;
    vec<rect> to_first; vec<rect> to_second;
    for(auto i : *rects){
        if((i*divide.first).valid()){
            if((i*divide.first)==divide.first) val[0]++;
            else to_first.pb(i*divide.first);
        }
        if((i*divide.second).valid()){
            if((i*divide.second)==divide.second) val[1]++;
            else to_second.pb(i*divide.second);
        }
    }
    vec<int> vec1 = process(&to_first, divide.first);
    vec<int> vec2 = process(&to_second, divide.second);

    for(int i=K-1; i>=0; i--){
        if(i-val[0]>=0) vec1[i]=vec1[i-val[0]];
        else vec1[i]=0;
        if(i-val[1]>=0) vec2[i]=vec2[i-val[1]];
        else vec2[i]=0;
    }

    vec<int> output;
    foru(i, K) output.pb(vec1[i]+vec2[i]);

    //cout << "range " << range.x.a << " " <<range.x.b << ", " << range.y.a << " " << range.y.b << endl;
    //foru(i, K) cout << output[i] << " "; cout << endl;

    return output;
}



int main()
{
    srand(0);
    //cin >> n; int k; cin >> k;

    //foru(i, n) cin >> a[i];
    //foru(i, n) cin >> b[i];
    n=N; int k=10;

    vec<int> deck;
    foru(i, 2*n) deck.pb(i+1);
    random_shuffle(deck.begin(), deck.end());
    foru(i, n) a[i]=deck[i];
    foru(i, n) b[i]=deck[i+n];

    foru(i, n-1){ ///ADDING EDGES
        ///A C
        ///B D
        add_edge(a[i], b[i], a[i+1], b[i+1]);
        add_edge(a[i+1], b[i+1], a[i], b[i]);
    }
    add_edge(a[n-1], b[n-1], a[0], b[0]);
    add_edge(a[0], b[0], a[n-1], b[n-1]);

    /*cout << "BEGINT RECTS" << endl;
    for(auto i : rectangles){
        cout << i.x.a << " " << i.x.b << ", " << i.y.a << " " << i.y.b << endl;
    }
    cout << "END" << endl;*/

    vec<int> output = process(&rectangles, make_rect(make_seg(1, 2*n), make_seg(1, 2*n)));

    cout << output[0] + output[2] - (2*n)*(2*n) + (2*n)*(2*n+1)/2 << " ";
    fors(i, k, 1) cout << output[2*(i+1)] << " ";

    return 0;
}

詳細信息

Subtask #1:

score: 0
Time Limit Exceeded

Test #1:

score: 0
Time Limit Exceeded

input:

10 1
6 18 4 17 1 8 7 13 5 10
2 20 3 11 15 12 19 16 14 9

output:


result:


Subtask #2:

score: 0
Time Limit Exceeded

Test #16:

score: 0
Time Limit Exceeded

input:

2 4
1 2
4 3

output:


result:


Subtask #3:

score: 0
Time Limit Exceeded

Test #34:

score: 0
Time Limit Exceeded

input:

500 10
917 838 302 172 930 427 28 597 459 846 477 474 4 764 33 821 250 204 653 309 142 916 795 928 387 956 810 433 973 609 226 556 547 540 860 847 535 147 768 619 448 52 551 131 294 892 423 241 363 117 566 285 702 230 6 624 358 802 672 641 384 639 911 251 823 750 587 865 751 890 604 317 473 606 998 ...

output:


result:


Subtask #4:

score: 0
Time Limit Exceeded

Test #51:

score: 0
Time Limit Exceeded

input:

100000 1
96176 27939 172191 74850 13479 117742 8634 21501 87321 149607 137789 134176 152101 180468 138683 166438 7726 31523 144362 26825 69995 74641 50479 72511 84577 185202 80203 157069 16984 58419 129101 172394 1618 195274 94592 35724 186278 93215 35874 2038 125395 20762 171892 53749 678 174925 13...

output:


result:


Subtask #5:

score: 0
Time Limit Exceeded

Test #61:

score: 0
Time Limit Exceeded

input:

20000 1
8260 23162 19083 31764 38686 5100 19437 18310 29053 16504 25374 30501 7543 30973 12153 5191 24580 3044 23328 33054 31229 26909 10407 33096 22917 26256 5677 13524 16383 36303 27681 25325 2346 30364 23195 6239 24636 2591 24756 17408 20987 35844 10387 25215 22822 31666 39853 30752 36965 8863 35...

output:


result:


Subtask #6:

score: 0
Time Limit Exceeded

Test #77:

score: 0
Time Limit Exceeded

input:

20000 10
37122 3130 15044 10634 29395 31698 29227 38486 30743 16224 36762 21225 34434 7049 5922 29646 17043 2684 30346 11095 29406 16909 26412 8343 29837 8721 28099 8734 7717 29088 6414 27191 13096 8463 34156 23605 31577 4853 39185 24977 28983 34919 10330 1303 23468 11457 17442 28837 16603 31324 424...

output:


result:


Subtask #7:

score: 0
Time Limit Exceeded

Test #96:

score: 0
Time Limit Exceeded

input:

100000 1
184488 199575 61547 186158 115443 82615 177342 64604 124208 4012 152444 113522 105138 104715 64740 152490 175932 130353 169948 187430 30884 108488 12761 28267 180529 162418 98945 127768 181574 92995 74927 17992 52128 144406 91892 165442 133627 58061 70318 156100 159695 56046 14083 192791 76...

output:


result:


Subtask #8:

score: 0
Time Limit Exceeded

Test #109:

score: 0
Time Limit Exceeded

input:

100000 10
13763 82869 153448 151170 185611 191283 101826 196257 150421 49313 96588 32246 110056 73755 9887 12523 88212 112364 28378 131033 63099 102930 78232 166326 42025 145005 26580 85545 114549 71238 19865 71364 183284 21738 132799 134266 129286 50677 118977 17635 110174 85984 57815 147687 131631...

output:


result:


Subtask #9:

score: 0
Time Limit Exceeded

Test #122:

score: 0
Time Limit Exceeded

input:

100000 1
173206 29172 157020 147149 12220 145352 172784 36710 183091 187710 142752 23844 81586 161419 87210 154300 66402 175548 62953 30212 149421 117646 193418 118516 177795 115642 176042 126287 14433 17937 105013 14605 143898 132929 143591 115108 42509 177469 90041 168554 70665 11736 145789 93906 ...

output:


result:


Subtask #10:

score: 0
Time Limit Exceeded

Test #140:

score: 0
Time Limit Exceeded

input:

100000 10
57693 110342 28705 133926 61784 186038 51305 155569 48140 115185 14169 141018 165711 24907 12001 165455 122449 21315 93989 187573 166405 193098 3306 189403 2421 23963 28619 50447 23589 121975 112280 17930 2499 90579 103377 113266 119659 153038 102862 35946 124741 136376 146205 141476 11481...

output:


result: