QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102899#5254. Differencesfz_zslTL 0ms0kbC++14710b2023-05-03 19:48:392023-05-03 19:48:42

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-03 19:48:42]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-05-03 19:48:39]
  • 提交

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;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: