이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n, m, K; cin >> n >> m >> K;
vector<pair<string,int>> v(n);
int cnt = 1;
for(auto &x : v)cin >> x.first, x.second = cnt++;
random_shuffle(v.begin(),v.end());
random_shuffle(v.begin(),v.end());
random_shuffle(v.begin(),v.end());
vector<int> no(n,0);
vector<vector<int>> sta(m,vector<int>(26,0));
for(int i = 0; i < n; ++i){
for(int j = 0; j < m; ++j){
sta[j][v[i].first[j]-'A']++;
}
}
for(int i = 0; i < n; ++i){
int cn = 0;
for(int j = 0; j < m; ++j){
cn+=sta[j][v[i].first[j]-'A'];
}
cn-=m;
if(cn != (n-1)*(m-K))no[i] = 1;
}
for(int i = 0; i < n; ++i){
if(no[i])continue;
for(int j = i+1; j < n; ++j){
int cn = 0;
for(int k = 0; k < m; ++k){
if(v[i].first[k] != v[j].first[k])cn++;
}
if(cn != K){no[j] = 1, no[i] = 1;break;}
}
if(no[i])continue;
for(int j = 0; j < i; ++j){
int cn = 0;
for(int k = 0; k < m; ++k){
if(v[i].first[k] != v[j].first[k])cn++;
}
if(cn != K){no[j] = 1, no[i] = 1;break;}
}
if(!no[i]){
cout << v[i].second << '\n';
return 0;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |