This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
const int N=4200;
mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
bitset<N> b[N][2];
int cnt[N][4];
int dif[N][N];
int diff(int i, int j) {
if(dif[i][j]>=0)return dif[i][j];
return dif[i][j]=((b[i][0]^b[j][0])|(b[i][1]^b[j][1])).count();
}
int main () {
cin.tie(0)->sync_with_stdio(0);
int n, m, k;
cin >> n >> m >> k;
memset(dif, -1, sizeof dif);
string a[n];
for(int i =0 ;i<n;i++) {
cin >> a[i];
for(int j =0 ;j<m;j++) {
if(a[i][j]=='A') {
b[i][0][j]=b[i][1][j]=1;
cnt[j][0]++;
}
else if(a[i][j]=='C') {
b[i][0][j]=1;
b[i][1][j]=0;
cnt[j][1]++;
}
else if(a[i][j]=='G') {
b[i][0][j]=0;
b[i][1][j]=1;
cnt[j][2]++;
}
else{
cnt[j][3]++;
}
}
}
bool check[n];
memset(check, 0, sizeof check);
int cc=0;
vector<int> idd(n);
iota(idd.begin(), idd.end(), 0);
shuffle(idd.begin(), idd.end(), rng);
for(int i:idd) {
int sum=0;
for(int j = 0;j<m;j++) {
if(a[i][j]=='A')sum+=cnt[j][0]-1;
else if(a[i][j]=='C')sum+=cnt[j][1]-1;
else if(a[i][j]=='G')sum+=cnt[j][2]-1;
else sum+=cnt[j][3]-1;
}
if(sum==(m-k)*(n-1)) {
cc++;
bool ck=1;
for(int j:idd) {
if(j==i)continue;
if(diff(i,j)!=k) {
ck=false;
break;
}
}
if(ck) {
cout << i+1 << "\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... |