QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#102885 | #5254. Differences | zswzswzsw | TL | 0ms | 0kb | C++14 | 671b | 2023-05-03 19:31:04 | 2023-05-03 19:31:09 |
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;
for(int i=0;i<m;i++)if(aa[i]!=bb[i]&&(++tmp)>k)break;
return tmp==k;
}
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;
}
详细
Test #1:
score: 0
Time Limit Exceeded
input:
3585 4096 2048 ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...