QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#526581 | #5254. Differences | solar_express# | TL | 0ms | 0kb | C++20 | 1.3kb | 2024-08-21 17:58:53 | 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...