이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for (int i = s; i <= e; ++i)
#define rrep(i,s,e) for (int i = s; i >= e; --i)
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
srand(7);
int n, m, k; cin >> n >> m >> k;
if (m>1800) {
bitset<4100> x[n];
rep (i,0,n-1) {
string s; cin >> s;
rep (j,0,m-1) if (s[j]=='A') x[i] |= bitset<4100>(1)<<j;
}
vi order(n);
iota(all(order), 0);
random_shuffle(all(order));
int s[n] = {};
rep (iii,0,n-1) {
int i = order[iii];
if (s[i]) continue;
bool suc = 1;
rep (ij,0,n-1) {
int j = order[ij];
if (i==j) continue;
int cnt = (x[i]^x[j]).count();
if (cnt!=k) {
s[j] = 1;
suc = 0;
break;
}
}
if (suc) {
cout << i+1 << "\n";
break;
}
}
}
else {
bitset<1800> x[n][4];
unordered_map<char, int> mp;
mp['A'] = 0;
mp['C'] = 1;
mp['G'] = 2;
mp['T'] = 3;
rep (i,0,n-1) {
string s; cin >> s;
rep (j,0,m-1) x[i][mp[s[j]]] |= bitset<1800>(1)<<j;
}
vi order(n);
iota(all(order), 0);
random_shuffle(all(order));
int s[n] = {};
rep (iii,0,n-1) {
int i = order[iii];
if (s[i]) continue;
bool suc = 1;
rep (ij,0,n-1) {
int j = order[ij];
if (i==j) continue;
int cnt = 0;
rep (l,0,3) cnt += (x[i][l]^x[j][l]).count();
if (cnt/2!=k) {
s[j] = 1;
suc = 0;
break;
}
}
if (suc) {
cout << i+1 << "\n";
break;
}
}
}
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... |