이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("bmi,avx2,popcnt")
#include <bits/stdc++.h>
#define lli long long int
#define ld long double
#define pb push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.begin(), x.end()
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
using namespace std;
void fastio() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}
const int N = 4102;
const int INF = 1e9 + 500;
const int MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r) {
return uniform_int_distribution<int>(l, r)(rng);
}
array<array<bitset<N>, N>, 4> s;
array<array<int, N>, N> dif;
int n, m, k;
bitset<N> tmp;
bitset<N> vis;
void solve() {
cin >> n >> m >> k;
k *= 2;
vector<int> perm(n), rperm(n);
REP(i, n) perm[i] = i;
REP(i, n) swap(perm[i], perm[rand(0, i)]);
REP(i, n) rperm[perm[i]] = i;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
char t;
cin >> t;
s[0][perm[i]][j] = (t == 'A');
s[1][perm[i]][j] = (t == 'C');
s[2][perm[i]][j] = (t == 'G');
s[3][perm[i]][j] = (t == 'T');
}
}
REP(i, n) REP(j, n) dif[i][j] = -1;
REP(i, n) vis[i] = 0;
for(int i = 0; i < n; i++) {
if(vis[i]) continue;
for(int j = 0; j < n; j++) {
if(i == j) continue;
if(dif[i][j] == -1) {
dif[i][j] = dif[j][i] = 0;
REP(z, 4) {
tmp = s[z][i] ^ s[z][j];
dif[i][j] += (int)tmp.count();
dif[j][i] += (int)tmp.count();
if(dif[i][j] > k) {
break;
}
}
}
if(dif[i][j] != k) {
vis[i] = vis[j] = 1;
break;
}
}
if(!vis[i]) {
cout << rperm[i] + 1 << "\n";
return;
}
}
}
signed main() {
fastio();
solve();
}
# | 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... |