• 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

    待填坑

  • 相关阅读:
    技术收集
    Entity Framework的扩展库
    暂时收集
    php 处理高并发的思路
    nginx缓存优先级(缓存问题者必看)
    mysql5.5主从配置
    php源码编译常见错误解决方案
    今天开始要改变模式了
    nrpe 在ubuntu上安装遇到的问题
    zendstudio 10下载汉化
  • 原文地址:https://www.cnblogs.com/mollnn/p/12664323.html
Copyright © 2020-2023  润新知