QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#102730 | #5254. Differences | csw_ccc# | TL | 0ms | 0kb | C++14 | 1013b | 2023-05-03 16:41:02 | 2023-05-03 16:41:03 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Time Limit Exceeded
input:
3585 4096 2048 ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...