이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define foru(i, l, r) for(int i = l; i <= r; i++)
#define ford(i, r, l) for(int i = r; i >= l; i--)
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;
const int N = 4005;
const int oo = 1e18 + 7, mod = 1e9 + 7;
int n, m, K;
int a[N][N];
int ha[256];
int tol[N];
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r){
int temp = rng() % (r - l + 1);
temp = (temp + (r - l + 1)) % (r - l + 1);
return temp + l;
}
void process(){
ha[0] = 1, ha[6] = 2, ha['T' - 'A'] = 3, ha[2] = 4;
cin >> n >> m >> K;
//cout << n << " " << m << " " << K << "\n";
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
char c;
cin >> c;
a[i][j] = ha[c - 'A'];
//cout << a[i][j] << "\n";
}
}
for(int itr = 1; itr <= 70000; itr++){
//if(se.size() )
int sum = 0;
int temp1 = rnd(1, n), temp2 = rnd(1, n);
while(temp2 == temp1) temp2 = rnd(1, n);
for(int k = 1; k <= m; k++) sum += (a[temp1][k] != a[temp2][k]);
//cout << i << " " << j << " " << sum << "\n";
if(sum != K){
tol[temp1] = 1, tol[temp2] = 1;
}
}
for(int i = 1; i <= n; i++){
if(!tol[i]){
bool ck = 1;
for(int j = 1; j <= n; j++){
if(i == j) continue;
int sum = 0;
for(int k = 1; k <= m; k++) sum += (a[i][k] != a[j][k]);
if(sum == m){
ck = 0;
break;
}
}
if(ck){
cout << i;
return;
}
}
}
//int cnt = 0;
}
signed main(){
ios_base::sync_with_stdio(0);
process();
}
# | 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... |