QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#102899 | #5254. Differences | fz_zsl | TL | 0ms | 0kb | C++14 | 710b | 2023-05-03 19:48:39 | 2023-05-03 19:48:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=501000;
int n,m,k;
string st[N];
long long res[N];
int cnt[28];
bool chk(string &aa,string &bb){
int tmp=0,j=0;
for(int i=0;i<m;i++){
if(aa[i]!=bb[i])++tmp;
if(tmp>k)++j;
}
return tmp==k&&max(0, tmp-k)==j;
}
int main()
{
cin>>n>>m>>k;
for(int i=1;i<=n;i++)cin>>st[i];
for(int now=0;now<m;now++)
{
for(int i=0;i<26;i++)cnt[i]=0;
for(int i=1;i<=n;i++)cnt[st[i][now]-'A']++;
for(int i=1;i<=n;i++)res[i]+=(n-cnt[st[i][now]-'A']);
}
for(int i=1;i<=n;i++)if(res[i]==1ll*(n-1)*k){
bool tg=1;
for(int j=1;j<=n;j++)if(i!=j&&!chk(st[i],st[j])){tg=0;break;}
if(tg)return cout<<i,0;
}cout<<0;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3585 4096 2048 ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...