이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long lo;
typedef pair< lo,lo > PII;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 5005;
const lo mod = 1000000007;
int n,m,b[li],a[li],k,flag,t,dp[li][li],vis[li];
int cev;
string s[li];
vector<int> v,v1;
int main(void){
cin>>n>>m>>k;
FOR{
cin>>s[i];
}
//~ int gez=0;
//~ int say=0;
for(int j=2;j<=n;j++){
cev=0;
for(int jj=0;jj<m;jj++){
if(s[1][jj]!=s[j][jj])cev++;
}
if(cev==k){v.pb(j);}
}
for(int j=1;j<=n;j++){
cev=0;
if(j==2)continue;
for(int jj=0;jj<m;jj++){
if(s[2][jj]!=s[j][jj])cev++;
}
if(cev==k){v1.pb(j);}
}
v.pb(1);
v1.pb(2);
//~ cout<<v1.size()<<endl;
//~ cout<<v[0]<<" : : "<<v[1]<<endl;
if(v.size()<v1.size()){
for(int i=0;i<(int)v.size();i++){
int yes=0;
for(int j=1;j<=n;j++){
if(j==v[i])continue;
cev=0;
for(int jj=0;jj<m;jj++){
if(s[v[i]][jj]!=s[j][jj])cev++;
}
if(cev==k)yes++;
}
//~ cout<<yes<<endl;
if(yes==n-1){printf("%d\n",v[i]);return 0;}
}
}
else{
for(int i=0;i<(int)v1.size();i++){
int yes=0;
for(int j=1;j<=n;j++){
if(j==v1[i])continue;
cev=0;
for(int jj=0;jj<m;jj++){
if(s[v1[i]][jj]!=s[j][jj])cev++;
}
if(cev==k)yes++;
}
//~ cout<<yes<<" "<<i<<" "<<v1[i]<<endl;
if(yes==n-1){printf("%d\n",v1[i]);return 0;}
}
}
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... |