3 条题解
-
0
#include<bits/stdc++.h> using namespace std; const int N=2e3+5; string s; long long cnt[30],cnt2[30]; int main() { ios::sync_with_stdio(false); cin.tie(0); long long T; cin>>T; while(T--) { long long n,len; cin>>n>>len; memset(cnt,0,sizeof(cnt)); cin>>s; for(long long i=0;i<len;i++) { cnt[s[i]-97]++; } bool b1=true; for(long long i=2;i<=n;i++) { string p=s; cin>>s; long long cnt3=0; if(b1==true) { for(long long j=0;j<len;j++) { if(s[j]!=p[j]) { cnt3++; } if(cnt3>4) { b1=false; break; } } } memset(cnt2,0,sizeof(cnt)); for(long long j=0;j<len;j++) { cnt2[s[j]-97]++; } for(long long j=0;j<26;j++) { if(cnt2[j]!=cnt[j]) { b1=false; } } } if(b1==false) { cout<<"NO\n"; }else { cout<<"YES\n"; } } }
信息
- ID
- 2306
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 9
- 标签
- 递交数
- 159
- 已通过
- 18
- 上传者