zoukankan      html  css  js  c++  java
  • codeforces 527C:STL set

    x和y各用一个set保存切割点

    L[k] H[k]记录长度为k的线段有几个

    每添加一个切点,更新L[] H[],然后找到各找到最大值,相乘就是答案

    关键是学学set的使用

    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    #include"cstdio"
    #include"queue"
    #include"cmath"
    #include"stack"
    #include"iostream"
    #include"algorithm"
    #include"cstring"
    #include"queue"
    #include"map"
    #include"set"
    #include"vector"
    #define ll long long
    #define mems(a,b) memset(a,b,sizeof(a))
    #define ls pos<<1
    #define rs pos<<1|1
    
    using namespace std;
    const int MAXN = 200500;
    const int MAXE = 200500;
    const int INF = 0x3f3f3f3f;
    
    set<int> h,v;
    int L[MAXN],H[MAXN];
    
    int main(){
        int x,y,n,ch=0,cv=0;
        scanf("%d%d%d",&y,&x,&n);
        mems(L,0);
        mems(H,0);
        h.insert(0);v.insert(0);
        h.insert(x);v.insert(y);
        int mxx=x,mxy=y;
        L[x]=H[y]=1;
        for(int i=0;i<n;i++){
            char arr[5];
            int t;
            set<int>::iterator l,r,mid;
            scanf("%s %d",arr,&t);
            if(arr[0]=='H'){
                h.insert(t);
                l=r=mid=h.find(t);
                l--;r++;
                L[*r-*l]--;
                L[*r-*mid]++;
                L[*mid-*l]++;
                if(!L[mxx]) while(!L[mxx]) mxx--;
            }
            else{
                v.insert(t);
                l=r=mid=v.find(t);
                l--;r++;
                H[*r-*l]--;
                H[*r-*mid]++;
                H[*mid-*l]++;
                if(!H[mxy]) while(!H[mxy]) mxy--;
            }
            //cout<<mxx<<'	'<<mxy<<endl;
            printf("%I64d
    ",(ll)mxx*mxy);
        }
        return 0;
    }
  • 相关阅读:
    SQL2014还原到2008
    SQL SERVER2014 安装 Error code 0x858C001B.
    c++builder XE7 C++11 C++0x 新语法
    c++Builder XE6 MD5 加密算法 BASE64 URL 编码
    手机新功能
    xe fmx 怎么改变button颜色
    XE6 任务栏 控件
    js里面return 和 return false的区别
    web.xml的contextConfigLocation作用及自动加载applicationContext.xml
    mybatis-config.xml配置
  • 原文地址:https://www.cnblogs.com/luxiaoming/p/5137624.html
Copyright © 2011-2022 走看看