繁华模拟赛 Evensgn与字符矩阵-LMLPHP

繁华模拟赛 Evensgn与字符矩阵-LMLPHP

繁华模拟赛 Evensgn与字符矩阵-LMLPHP

繁华模拟赛 Evensgn与字符矩阵-LMLPHP

#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = ;
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 = ;i <= n;i++){
scanf("%s",s[i]+);
}
memset(vis,true,sizeof(vis));
for(int i = ;i <= m;i++){
ok = true;
for(int j = ;j <= n;j++){
if(vis[j]&& s[j][i] < s[j-][i]){
ans++;
ok = false;
break;
}
}
if(ok){
for(int j = ;j <= n;j++){
if(s[j][i] != s[j-][i]) vis[j] = false;
}
}
}
cout<<ans;
return ;
} #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[][];
int rk[],trk[];
int main()
{
int n,m,i,j,ans=,flag;
freopen("evensgn.in","r",stdin);
freopen("evensgn.out","w",stdout);
cin>>n>>m;
for(i=;i<=n;i++)
scanf("%s",s[i]+);
for(j=;j<=m;j++)
{
flag=;
trk[]=;
for(i=;i<n;i++)
{
if(rk[i]<rk[i+])
{
trk[i+]=trk[i]+;
continue;
}
else
{
if(s[i][j]>s[i+][j])
{
ans++;
//printf("j=%d i=%d\n",j,i);
flag=;
break;
}
else if(s[i][j]<s[i+][j])
trk[i+]=trk[i]+;
else trk[i+]=trk[i];
}
}
if(!flag)
for(i=;i<=n;i++)
rk[i]=trk[i];
}
cout<<ans<<endl;
return ;
}
// davidlee1999WTK 2014/
// srO myk Orz
//ios::sync_with_stdio(false);
04-27 01:16