首页 > 代码库 > 繁华模拟赛 Evensgn与字符矩阵
繁华模拟赛 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 secondusing 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与字符矩阵
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。