繁华模拟赛 Evensgn与字符矩阵

Posted ACforever

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了繁华模拟赛 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\n",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);

 

以上是关于繁华模拟赛 Evensgn与字符矩阵的主要内容,如果未能解决你的问题,请参考以下文章

繁华模拟赛 Evensgn剪树枝

繁华模拟赛 Evensgn的债务

繁华模拟赛 Evensgn玩序列

Evensgn 剪树枝

繁华模拟赛 vicent的字符串

NOIP模拟赛Evensgn 的债务 乱搞