zoukankan      html  css  js  c++  java
  • Codeforces Round #632 (Div. 2) 总结

    仍然按照惯例打半场,前 20 分钟签完 ABC,而后因 D 写 WA 懵逼到死

    A

    很容易想到只让第一个格子为 W 即可

    #include <bits/stdc++.h>
    using namespace std;
    
    signed main() {
        ios::sync_with_stdio(false);
        int t,n,m;
        cin>>t;
        while(t--) {
            cin>>n>>m;
            for(int i=1;i<=n;i++) {
                for(int j=1;j<=m;j++) {
                    if(i==1 && j==1) cout<<"W";
                    else cout<<"B";
                }
                cout<<endl;
            }
        }
    }
    
    

    B

    (b[i]>a[i])(a[1..i-1]) 中必须有 (1),反之亦然

    #include <bits/stdc++.h>
    using namespace std;
    
    #define int long long
    const int N = 1000005;
    int t,n,a[N],b[N];
    
    signed main() {
        ios::sync_with_stdio(false);
        cin>>t;
        while(t--) {
            cin>>n;
            for(int i=1;i<=n;i++) cin>>a[i];
            for(int i=1;i<=n;i++) cin>>b[i];
            int ng=0,ps=0,fg=1;
            for(int i=1;i<=n;i++) {
                if(b[i]>a[i] && ps==0) fg=0;
                if(b[i]<a[i] && ng==0) fg=0;
                if(a[i]==-1) ng=1;
                if(a[i]==1) ps=1;
            }
            if(fg) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
    

    C

    转化为前缀和相等,然后尺取法即可

    #include <bits/stdc++.h>
    using namespace std;
    
    #define int long long
    const int N = 1000005;
    
    int n,a[N],s[N],ans=0;
    
    set <int> st;
    
    signed main() {
        ios::sync_with_stdio(false);
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        for(int i=1;i<=n;i++) s[i]=s[i-1]+a[i];
        int pos=1;
        st.insert(0);
        for(int i=1;i<=n;i++) {
            while(pos<=n && st.find(s[pos])==st.end()) {
                st.insert(s[pos]);
                ++pos;
            }
            ans+=pos-i;
            if(st.find(s[i-1])!=st.end()) st.erase(s[i-1]);
        }
        cout<<ans;
    }
    
    

    D

    WA掉了,待填坑

    F

    待填坑

  • 相关阅读:
    P2380狗哥采矿(状态不易设计)
    P2320鬼谷子的钱袋(分治)
    树型背包(模板)
    Tarjan缩点割点(模板)
    最短路记录路径(模板)
    P1790 矩形分割(隐含的电风扇)
    P1725 琪露诺(单调队列优化)
    BZOJ3236: [Ahoi2013]作业
    BZOJ3809: Gty的二逼妹子序列
    BZOJ2190: [SDOI2008]仪仗队
  • 原文地址:https://www.cnblogs.com/mollnn/p/12664323.html
Copyright © 2011-2022 走看看