Submission #1363491

#TimeUsernameProblemLanguageResultExecution timeMemory
1363491madamadam3Genetics (BOI18_genetics)C++20
0 / 100
18 ms6336 KiB
#include <bits/stdc++.h>
using namespace std;

/*
trying the bitset idea with the subtasks "dna has only A or C" worked for the smaller one, but failed
for the larger one until i cut the constant in half by only 
*/

int main() {
    cin.tie(0)->sync_with_stdio(0);
    
    int n, m, k; cin >> n >> m >> k;
    vector<string> seq(n); for (int i = 0; i < n; i++) cin >> seq[i];
    using b = bitset<4100>;

    vector<int> idx(n); iota(idx.begin(), idx.end(), 0);
    vector<b> s1(n), s2(n), s3(n), s4(n);
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) {
        if (seq[idx[i]][j] == 'A') s1[i][j] = 1;
        if (seq[idx[i]][j] == 'T') s2[i][j] = 1;
        if (seq[idx[i]][j] == 'C') s3[i][j] = 1;
        if (seq[idx[i]][j] == 'G') s4[i][j] = 1;
    }

    vector<int> cnt(n);
    mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
    shuffle(idx.begin(), idx.end(), rng);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            int t = 0;
            t += (s1[i] ^ s1[j]).count();
            t += (s2[i] ^ s2[j]).count();
            t += (s3[i] ^ s3[j]).count();
            t += (s4[i] ^ s4[j]).count();

            if (t == 2*k) cnt[i]++, cnt[j]++;
        }

        if (cnt[i] == n-1) {
            cout << idx[i]+1 << "\n";
            break;
        }
    }
    return 0;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...