Submission #70996579


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
 
#define int long long

struct rectangle{
    int topX,bottomX,leftY,rightY;
    rectangle(int t,int b,int l,int r):topX(t),bottomX(b),leftY(l),rightY(r){}
    optional<pair<rectangle,rectangle>> breakX(int A,int B){
        if(bottomX>=A){
            leftY+=B;
            rightY+=B;
            return nullopt;
        } else if(topX<A){
            leftY-=B;
            rightY-=B;
            return nullopt;
        }
        rectangle niche = {A-1,bottomX,leftY,rightY};
        rectangle uppar = {topX,A,leftY,rightY};
        niche.breakX(A,B);
        uppar.breakX(A,B);
        return make_pair(niche,uppar);
    }
    optional<pair<rectangle,rectangle>> breakY(int A,int B){
        if(A<=leftY){
            topX+=B;
            bottomX+=B;
            return nullopt;
        } else if(rightY<A){
            topX-=B;
            bottomX-=B;
            return nullopt;
        }
        rectangle left = {topX,bottomX,leftY,A-1};
        rectangle right = {topX,bottomX,A,rightY};
        left.breakY(A,B);
        right.breakY(A,B);
        return make_pair(left,right);
    }
    bool fuck(rectangle &other){
        if(rightY+1==other.leftY){
            if(min(topX,other.topX)>=max(bottomX,other.bottomX))return true;
        }
        if(topX+1==other.bottomX){
            if(min(rightY,other.rightY)>=max(leftY,other.leftY))return true;
        }
        return false;
    }
    int sussy(){
        return (rightY-leftY+1)*(topX-bottomX+1);
    }
};

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,X,Y;
    cin >> N >> X >> Y;
    vector<rectangle> rect;
    rect.emplace_back(X-1,0,0,Y-1);
    for(int i=1;i<=N;i++){
        char C;int A,B;cin>>C>>A>>B;
        vector<rectangle> rect2;
        if(C=='X'){
            for(auto&xxx:rect){
                auto t = xxx.breakX(A,B);
                if(!t)rect2.emplace_back(xxx);
                else {
                    rect2.emplace_back(t->first);
                    rect2.emplace_back(t->second);
                }
            }
        } else {
            for(auto&xxx:rect){
                auto t = xxx.breakY(A,B);
                if(!t)rect2.emplace_back(xxx);
                else {
                    rect2.emplace_back(t->first);
                    rect2.emplace_back(t->second);
                }
            }
        }
        swap(rect,rect2);
    }
    N = rect.size();
    vector<bool> visited(N);
    vector<int> ans;
    auto dfs = [&](auto&& self,int x)->void{
        visited[x]=true;
        ans.back()+=rect[x].sussy();
        for(int i=0;i<N;i++)if(!visited[i] and (rect[x].fuck(rect[i]) or rect[i].fuck(rect[x])))self(self,i);
    };
    for(int i=0;i<N;i++)if(!visited[i]){
        ans.emplace_back(0);
        dfs(dfs,i);
    }
    sort(ans.begin(),ans.end());
    cout << ans.size() << '\n';
    for(int&i:ans)cout<<i<<' ';
}

Submission Info

Submission Time
Task D - Suddenly, A Tempest
User Unforgettablepl
Language C++ IOI-Style(GNU++20) (GCC 14.2.0)
Score 425
Code Size 3021 Byte
Status AC
Exec Time 0 ms
Memory 1680 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 2
AC × 96
Set Name Test Cases
Sample 00-sample-01.txt, 00-sample-02.txt
All 00-sample-01.txt, 00-sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 01-27.txt, 01-28.txt, 01-29.txt, 01-30.txt, 01-31.txt, 01-32.txt, 01-33.txt, 01-34.txt, 01-35.txt, 01-36.txt, 01-37.txt, 01-38.txt, 01-39.txt, 01-40.txt, 01-41.txt, 01-42.txt, 01-43.txt, 01-44.txt, 01-45.txt, 01-46.txt, 01-47.txt, 01-48.txt, 01-49.txt, 01-50.txt, 01-51.txt, 01-52.txt, 01-53.txt, 01-54.txt, 01-55.txt, 01-56.txt, 01-57.txt, 01-58.txt, 01-59.txt, 01-60.txt, 01-61.txt, 01-62.txt, 01-63.txt, 01-64.txt, 01-65.txt, 01-66.txt, 01-67.txt, 01-68.txt, 01-69.txt, 01-70.txt, 01-71.txt, 01-72.txt, 01-73.txt, 01-74.txt, 01-75.txt, 01-76.txt, 01-77.txt, 01-78.txt, 01-79.txt, 01-80.txt, 01-81.txt, 01-82.txt, 01-83.txt, 01-84.txt, 01-85.txt, 01-86.txt, 01-87.txt, 01-88.txt, 01-89.txt, 01-90.txt, 01-91.txt, 01-92.txt, 01-93.txt, 01-94.txt
Case Name Status Exec Time Memory
00-sample-01.txt AC 0 ms 1680 KiB
00-sample-02.txt AC 0 ms 1680 KiB
01-01.txt AC 0 ms 1680 KiB
01-02.txt AC 0 ms 1680 KiB
01-03.txt AC 0 ms 1680 KiB
01-04.txt AC 0 ms 1680 KiB
01-05.txt AC 0 ms 1680 KiB
01-06.txt AC 0 ms 1680 KiB
01-07.txt AC 0 ms 1680 KiB
01-08.txt AC 0 ms 1680 KiB
01-09.txt AC 0 ms 1680 KiB
01-10.txt AC 0 ms 1680 KiB
01-11.txt AC 0 ms 1680 KiB
01-12.txt AC 0 ms 1680 KiB
01-13.txt AC 0 ms 1680 KiB
01-14.txt AC 0 ms 1680 KiB
01-15.txt AC 0 ms 1680 KiB
01-16.txt AC 0 ms 1680 KiB
01-17.txt AC 0 ms 1680 KiB
01-18.txt AC 0 ms 1680 KiB
01-19.txt AC 0 ms 1680 KiB
01-20.txt AC 0 ms 1680 KiB
01-21.txt AC 0 ms 1680 KiB
01-22.txt AC 0 ms 1680 KiB
01-23.txt AC 0 ms 1680 KiB
01-24.txt AC 0 ms 1680 KiB
01-25.txt AC 0 ms 1680 KiB
01-26.txt AC 0 ms 1680 KiB
01-27.txt AC 0 ms 1680 KiB
01-28.txt AC 0 ms 1680 KiB
01-29.txt AC 0 ms 1680 KiB
01-30.txt AC 0 ms 1680 KiB
01-31.txt AC 0 ms 1680 KiB
01-32.txt AC 0 ms 1680 KiB
01-33.txt AC 0 ms 1680 KiB
01-34.txt AC 0 ms 1680 KiB
01-35.txt AC 0 ms 1680 KiB
01-36.txt AC 0 ms 1680 KiB
01-37.txt AC 0 ms 1680 KiB
01-38.txt AC 0 ms 1680 KiB
01-39.txt AC 0 ms 1680 KiB
01-40.txt AC 0 ms 1680 KiB
01-41.txt AC 0 ms 1680 KiB
01-42.txt AC 0 ms 1680 KiB
01-43.txt AC 0 ms 1680 KiB
01-44.txt AC 0 ms 1680 KiB
01-45.txt AC 0 ms 1680 KiB
01-46.txt AC 0 ms 1680 KiB
01-47.txt AC 0 ms 1680 KiB
01-48.txt AC 0 ms 1680 KiB
01-49.txt AC 0 ms 1680 KiB
01-50.txt AC 0 ms 1680 KiB
01-51.txt AC 0 ms 1680 KiB
01-52.txt AC 0 ms 1680 KiB
01-53.txt AC 0 ms 1680 KiB
01-54.txt AC 0 ms 1680 KiB
01-55.txt AC 0 ms 1680 KiB
01-56.txt AC 0 ms 1680 KiB
01-57.txt AC 0 ms 1680 KiB
01-58.txt AC 0 ms 1680 KiB
01-59.txt AC 0 ms 1680 KiB
01-60.txt AC 0 ms 1680 KiB
01-61.txt AC 0 ms 1680 KiB
01-62.txt AC 0 ms 1680 KiB
01-63.txt AC 0 ms 1680 KiB
01-64.txt AC 0 ms 1680 KiB
01-65.txt AC 0 ms 1680 KiB
01-66.txt AC 0 ms 1680 KiB
01-67.txt AC 0 ms 1680 KiB
01-68.txt AC 0 ms 1680 KiB
01-69.txt AC 0 ms 1680 KiB
01-70.txt AC 0 ms 1680 KiB
01-71.txt AC 0 ms 1680 KiB
01-72.txt AC 0 ms 1680 KiB
01-73.txt AC 0 ms 1680 KiB
01-74.txt AC 0 ms 1680 KiB
01-75.txt AC 0 ms 1680 KiB
01-76.txt AC 0 ms 1680 KiB
01-77.txt AC 0 ms 1680 KiB
01-78.txt AC 0 ms 1680 KiB
01-79.txt AC 0 ms 1680 KiB
01-80.txt AC 0 ms 1680 KiB
01-81.txt AC 0 ms 1680 KiB
01-82.txt AC 0 ms 1680 KiB
01-83.txt AC 0 ms 1680 KiB
01-84.txt AC 0 ms 1680 KiB
01-85.txt AC 0 ms 1680 KiB
01-86.txt AC 0 ms 1680 KiB
01-87.txt AC 0 ms 1680 KiB
01-88.txt AC 0 ms 1680 KiB
01-89.txt AC 0 ms 1680 KiB
01-90.txt AC 0 ms 1680 KiB
01-91.txt AC 0 ms 1680 KiB
01-92.txt AC 0 ms 1680 KiB
01-93.txt AC 0 ms 1680 KiB
01-94.txt AC 0 ms 1680 KiB