QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#537596#5254. DifferencesUESTC_DECAYALI#TL 0ms0kbC++20920b2024-08-30 16:24:442024-08-30 16:24:45

Judging History

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

  • [2024-08-30 16:24:45]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-08-30 16:24:44]
  • 提交

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

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: