QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102730#5254. Differencescsw_ccc#TL 0ms0kbC++141013b2023-05-03 16:41:022023-05-03 16:41:03

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 16:41:03]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2023-05-03 16:41:02]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include<string>
#include<cstdlib>
#include<algorithm>
using namespace std;

int n,m,k;
string str[200000+5];
int t[200000+5],s[200000+5];

bool getdis(const string &str1,const string &str2)
{
	int cnt=0;
	for(int i=0; i<m; i++)
	{
		if(str1[i]!=str2[i])
		{
			cnt++;
			if(cnt>k) return false;
		}
	}
	return cnt==k;
}

bool vis[200000+5];

int main()
{
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1;i<=n;i++){
		t[i]=i;
		s[i]=i;
	}
	random_shuffle(s+1,s+n+1);
	
	for(int i=1; i<=n; i++){
		//cin>>str[i]; 
		str[i].resize(m);
		scanf("%s",&str[i][0]);
	}
	for(int i=1; i<=n; i++)
	{
		int y=s[i];
		if(vis[y]) continue;
		random_shuffle(t+1,t+n+1);
		
		for(int j=1; j<=n; j++)
		{
			int x=t[j];
			if(x==y) continue;
			if(!getdis(str[y],str[x]))
			{
				vis[y]=vis[x]=true;
				break;
			}
		}
		
		if(!vis[y])
		{
			printf("%d\n",y);
			return 0;
		}
	}
	return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: