• 繁华模拟赛 Evensgn与字符矩阵


    #include<iostream>
    #include<cstdio>
    #include<string>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    const int maxn = 2050;
    int n,m,ans;
    char s[maxn][maxn];
    bool ok;
    bool vis[maxn];
    int main(){
        freopen("evensgn.in","r",stdin);
        freopen("evensgn.out","w",stdout);
        cin>>n>>m;
        for(int i = 1;i <= n;i++){
                scanf("%s",s[i]+1);
        }
        memset(vis,true,sizeof(vis));
        for(int i = 1;i <= m;i++){
            ok = true;
            for(int j = 2;j <= n;j++){
                if(vis[j]&& s[j][i] < s[j-1][i]){
                    ans++;
                    ok = false;
                    break;
                }
            }
            if(ok){
                for(int j = 2;j <= n;j++){
                    if(s[j][i] != s[j-1][i]) vis[j] = false;
                }
            }
        }
        cout<<ans;
        return 0;
    }
    
    #include<cstdio>
    #include<iostream>
    #include<algorithm>
    #include<cstring>
    #include<cmath>
    #include<vector>
    #include<queue>
    #include<map>
    #include<set>
    #include<stack>
    #include<cstdlib>
    #include<string>
    #include<bitset>
    #define INF 100000000
    #define fi first
    #define se second
    using namespace std;
    typedef long long LL;
    typedef pair<int,int> pii;
    char s[1005][1005];
    int rk[1005],trk[1005];
    int main()
    {
        int n,m,i,j,ans=0,flag;
        freopen("evensgn.in","r",stdin);
        freopen("evensgn.out","w",stdout);
        cin>>n>>m;
        for(i=1;i<=n;i++)
            scanf("%s",s[i]+1);
        for(j=1;j<=m;j++)
        {
            flag=0;
            trk[1]=0;
            for(i=1;i<n;i++)
            {
                if(rk[i]<rk[i+1])
                {
                    trk[i+1]=trk[i]+1;
                    continue;
                }
                else
                {
                    if(s[i][j]>s[i+1][j])
                    {
                        ans++;
                        //printf("j=%d i=%d
    ",j,i);
                        flag=1;
                        break;
                    }
                    else if(s[i][j]<s[i+1][j])
                        trk[i+1]=trk[i]+1;
                    else trk[i+1]=trk[i];
                }
            }
            if(!flag)
                for(i=1;i<=n;i++)
                    rk[i]=trk[i];
        }
        cout<<ans<<endl;
        return 0;
    }
    // davidlee1999WTK 2014/
    // srO myk Orz
    //ios::sync_with_stdio(false);
  • 相关阅读:
    面试系统化准备(三)——说辞
    2022年学习计划(一) k8s实战学习
    面试系统化准备(六)
    面试准备(九)——招聘要求
    面试准备(八)——学习怎么描述自己的项目经历
    DC2
    CVE202135042 Django order_by SQL注入 漏洞复现和分析
    Vulnstack红队(一)
    DC3
    Vulntargeta
  • 原文地址:https://www.cnblogs.com/hyfer/p/5875205.html
Copyright © 2020-2023  润新知