QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#526581#5254. Differencessolar_express#TL 0ms0kbC++201.3kb2024-08-21 17:58:532024-08-21 17:58:53

Judging History

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

  • [2024-08-21 17:58:53]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-08-21 17:58:53]
  • 提交

answer

#include<bits/stdc++.h>
#define N 100005
using namespace std;
string st[N];
set<int> s;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;++i) cin>>st[i];
    for(int i=1;i<=n;++i){
        if(s.empty()){
            s.insert(i);
        }else{
            vector<int> tbd;
            tbd.clear();
            set<int> :: iterator it=s.begin();
            while(it!=s.end()){
                int diff=0,id=*it;
                for(int j=0;j<m;++j)
                    if(st[id][j]!=st[i][j])
                        ++diff;
                if(diff!=k) tbd.push_back(id);
                ++it;
            }
            if(tbd.size()){
                for(auto v:tbd) s.erase(v);
            }else
                s.insert(i);
        }
    }
    set<int>::iterator it=s.begin();
    while(it!=s.end()){
        bool fl=1;
        int id=*it;
        for(int i=1;i<=n;++i)
            if(i!=id){
                int diff=0;
                for(int j=0;j<m;++j)
                    if(st[id][j]!=st[i][j])
                        ++diff;
                if(diff!=k) fl=0;
            }
        if(fl==1){
            cout<<id<<'\n';
            return 0;
        }
        ++it;
    }
    return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

3585 4096 2048
ABBBBBBAABAAAAAAAAAAAAABAABABBBABABAAAAABABAAAABAABAABBABBAABAABABBABAABBABBABABABBAAAABBABAABBBBABBBAABBBBBABAABAAABAAABBBBAAAABAABAABABABABBBBBABAAABAAABBAABABBABAABBAABBAABABBBBAABAAAABAABBABAAABBAAAAAABAABBABBABAABABBBAABABBABABBBAAAAABBBABABABBAABAAAABBBBABABAABBBABABABBAABBBABAB...

output:


result: