# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
262468 | sckmd | Genetics (BOI18_genetics) | C++14 | 1552 ms | 91232 KiB |
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;
#define MAXN 4101
int decode[678];
int a[MAXN][MAXN];
int howm[4][MAXN];
bitset <MAXN> b0[MAXN];
bitset <MAXN> b1[MAXN];
bitset <MAXN> b2[MAXN];
bitset <MAXN> b3[MAXN];
int n,m,k;
vector <int> z;
bool check(int idx)
{
z.clear();
for(int j = 0; j < n; j++)z.push_back(j);
random_shuffle(z.begin(),z.end());
for(auto id:z)
{
if(id==idx)continue;
int r = 0;
r += (b0[idx]^b0[id]).count();
r += (b1[idx]^b1[id]).count();
r += (b2[idx]^b2[id]).count();
r += (b3[idx]^b3[id]).count();
if(r != 2*k)return false;
}
return true;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
decode['A']=0;decode['C']=1;decode['T']=2;decode['G']=3;
cin >> n >> m >> k;
for(int i = 0; i < n; i++)
{
for(int j = 0; j < m; j++)
{
//int a;
char c;
cin >> c;
a[i][j]=decode[c];
if(a[i][j]==0)b0[i].set(j);
if(a[i][j]==1)b1[i].set(j);
if(a[i][j]==2)b2[i].set(j);
if(a[i][j]==3)b3[i].set(j);
howm[a[i][j]][j]++;
}
}
vector <int> vec;
for(int i = 0; i < n; i++)vec.push_back(i);
random_shuffle(vec.begin(),vec.end());
for(auto x:vec)
{
int uk = 0;
for(int j = 0; j < m; j++)
{
uk += (n-howm[a[x][j]][j]);
}
if(uk != k*(n-1))continue;
if(check(x))
{
cout << x+1 << "\n";
return 0;
}
}
return 0;
}
Compilation message (stderr)
# | 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... |