QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#537596 | #5254. Differences | UESTC_DECAYALI# | TL | 0ms | 0kb | C++20 | 920b | 2024-08-30 16:24:44 | 2024-08-30 16:24:45 |
answer
#include<bits/stdc++.h>
#define RI register int
#define CI const int&
using namespace std;
const int N=100005;
int n,m,k,valid[N]; string s[N];
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
int main()
{
ios::sync_with_stdio(0); cin.tie(0);
srand(time(0)); cin>>n>>m>>k;
for (RI i=1;i<=n;++i) cin>>s[i],valid[i]=1;
vector <int> vec; vec.reserve(n);
for (RI i=1;i<=n;++i) vec.push_back(i);
for (;;)
{
auto dist=[&](const string& A,const string& B)
{
int ret=0; for (RI i=0;i<m;++i) ret+=A[i]!=B[i]; return ret;
};
int x=vec[rnd()%vec.size()];
bool flag=1; for (RI i=1;i<=n;++i)
if (i!=x&&dist(s[i],s[x])!=k) flag=0,valid[i]=0;
if (flag) { cout<<x; break; }
valid[x]=0; vec.clear();
for (RI i=1;i<=n;++i) if (valid[i]) vec.push_back(i);
}
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...