Submission #532647

#TimeUsernameProblemLanguageResultExecution timeMemory
532647sidonGenetics (BOI18_genetics)C++17
46 / 100
2081 ms107168 KiB
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx", "avx2", "popcnt")
#include <bits/stdc++.h>
using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int Z = 4100;
 
int N, M, K;
bitset<Z*4> a[Z];
 
int g[100];
 
bool chk[Z][Z]; int cnt[Z][Z];

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
 
	g['C'] = 1;
	g['G'] = 2;
	g['T'] = 3;
 
	cin >> N >> M >> K;

 	vector<int> o(N);

	for(int i = 0; i < N; ++i) {
		string inp; cin >> inp;
		for(int j = 0; j < M; ++j)
			a[i][g[int(inp[j])] * Z + j] = 1;
		o[i] = i;
	}

	shuffle(begin(o), end(o), rng);

	for(const int &i : o) {
		bool ok = 1;

		a[i].flip();
 
		for(int j = 0; j < N; ++j) if(i != j) {
			int c = (chk[i][j] ? cnt[i][j] : (a[i] & a[j]).count());
 
			chk[j][i] = 1;
			cnt[j][i] = c;
 
			if(c != K) {
				ok = 0;
				break;
			}
		}
 
		if(ok) {
			cout << i + 1;
			return 0;
		}
 
		a[i].flip();
	}
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...