Submission #657660

#TimeUsernameProblemLanguageResultExecution timeMemory
657660MilosMilutinovicGenetics (BOI18_genetics)C++14
19 / 100
2095 ms75412 KiB
/**
 *    author:  wxhtzdy
 *    created: 10.11.2022 15:59:08
**/
#include <bits/stdc++.h>

using namespace std;

string c = "ACGT";

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);  
  int n, m, k;
  cin >> n >> m >> k;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  vector<int> order(n);
  iota(order.begin(), order.end(), 0);
  mt19937 rng(31413113);
  shuffle(order.begin(), order.end(), rng);
  const int N = 4100;
  vector<vector<bitset<N>>> f(n, vector<bitset<N>>(4));
  for (int i = 0; i < 2; i++) {
    for (int j : order) {
      for (int k = 0; k < m; k++) {
        f[j][i][k] = (c[i] == s[j][k] ? 1 : 0);  
      }
    }
  }
  vector<vector<int>> d(n, vector<int>(n));
  vector<bool> is(n, true);
  for (int ii = 0; ii < n; ii++) {
    int i = order[ii];
    for (int jj = ii + 1; jj < n; jj++) {
      int j = order[jj];
      if (!is[i] && !is[j]) {
        continue;
      }
      d[i][j] += (f[i][0] ^ f[j][0]).count() + (f[i][1] ^ f[j][1]).count();
      if (d[i][j] != k * 2) {
        is[i] = false;
        is[j] = false;
      }
    }
    if (is[i]) {
      cout << i + 1 << '\n';
      return 0;
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (d[i][j] != k * 2) {
        is[i] = false;
        is[j] = false;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    if (is[i]) {
      cout << i + 1 << '\n';
    }
  }
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...