题解:P17500 [ICPC 2026 Wuhan I] Rectangle Cutting

· · 题解

::::success[AC CODE]

#include <bits/stdc++.h>
using namespace std;
long long n,m;int q;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m>>q;
    map<long long,int> cx,cy,sx,sy;
    cx[0]=cx[n]=1;cy[0]=cy[m]=1;sx[n]=1;sy[m]=1;
    while(q--){
        int op;long long k;
        cin>>op>>k;
        if(op==1){
            auto r=cx.upper_bound(k);
            auto l=prev(r);
            long long L=l->first,R=r->first;
            if(--sx[R-L]==0)sx.erase(R-L);
            sx[k-L]++;
            sx[R-k]++;
            cx[k]=1;
        }else{
            auto r=cy.upper_bound(k);
            auto l=prev(r);
            long long L=l->first,R=r->first;
            if(--sy[R-L]==0)sy.erase(R-L);
            sy[k-L]++;
            sy[R-k]++;
            cy[k]=1;
        }cout<<(sx.rbegin()->first)*(sy.rbegin()->first)<<'\n';
    }
    return 0;
}

::::