Submission #878126

#TimeUsernameProblemLanguageResultExecution timeMemory
878126vjudge1Genetics (BOI18_genetics)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #define ll long long #define pb push_back const int N = 4100 + 4; int n, m, k; char s[N][N]; bitset<N> tmp, a[N], g[N], c[N], t[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); bool AC = true; cin >> n >> m >> k; for (int i = 0; i < n; ++i) { cin >> s[i]; for (int j = 0; j < m; ++j) { if (s[i][j] == 'A') { a[i][j] = true; } else if (s[i][j] == 'G') { g[i][j] = true; } else if (s[i][j] == 'C') { c[i][j] = true; } else if (s[i][j] == 'T') { t[i][j] = true; } } } for (int i = 0; i < n; ++i) { int cntOk = 0; for (int j = 0; j < n; ++j) { if (i == j) { continue; } int cnt = 0; tmp = a[i] & a[j]; cnt += tmp.count(); tmp = g[i] & g[j]; cnt += tmp.count(); tmp = c[i] & c[j]; cnt += tmp.count(); tmp = t[i] & t[j]; cnt += tmp.count(); // cout << i + 1 << ' ' << j + 1 << ' ' << cnt << '\n'; cntOk += (m - cnt == k); } if (cntOk == n - 1) { cout << i + 1; return 0; } } return 0; } #define ll long long #define pb push_back const int N = 4100 + 4; int n, m, k; char s[N][N]; bitset<N> tmp, a[N], g[N], c[N], t[N]; int main() { ios::sync_with_stdio(0); cin.tie(0); bool AC = true; cin >> n >> m >> k; for (int i = 0; i < n; ++i) { cin >> s[i]; for (int j = 0; j < m; ++j) { if (s[i][j] == 'A') { a[i][j] = true; } else if (s[i][j] == 'G') { g[i][j] = true; } else if (s[i][j] == 'C') { c[i][j] = true; } else if (s[i][j] == 'T') { t[i][j] = true; } } } for (int i = 0; i < n; ++i) { int cntOk = 0; for (int j = 0; j < n; ++j) { if (i == j) { continue; } int cnt = 0; tmp = a[i] & a[j]; cnt += tmp.count(); tmp = g[i] & g[j]; cnt += tmp.count(); tmp = c[i] & c[j]; cnt += tmp.count(); tmp = t[i] & t[j]; cnt += tmp.count(); // cout << i + 1 << ' ' << j + 1 << ' ' << cnt << '\n'; cntOk += (m - cnt == k); } if (cntOk == n - 1) { cout << i + 1; return 0; } } return 0; }

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:20:10: warning: unused variable 'AC' [-Wunused-variable]
   20 |     bool AC = true;
      |          ^~
genetics.cpp: At global scope:
genetics.cpp:75:11: error: redefinition of 'const int N'
   75 | const int N = 4100 + 4;
      |           ^
genetics.cpp:10:11: note: 'const int N' previously defined here
   10 | const int N = 4100 + 4;
      |           ^
genetics.cpp:77:5: error: redefinition of 'int n'
   77 | int n, m, k;
      |     ^
genetics.cpp:12:5: note: 'int n' previously declared here
   12 | int n, m, k;
      |     ^
genetics.cpp:77:8: error: redefinition of 'int m'
   77 | int n, m, k;
      |        ^
genetics.cpp:12:8: note: 'int m' previously declared here
   12 | int n, m, k;
      |        ^
genetics.cpp:77:11: error: redefinition of 'int k'
   77 | int n, m, k;
      |           ^
genetics.cpp:12:11: note: 'int k' previously declared here
   12 | int n, m, k;
      |           ^
genetics.cpp:78:6: error: redefinition of 'char s [4104][4104]'
   78 | char s[N][N];
      |      ^
genetics.cpp:13:6: note: 'char s [4104][4104]' previously declared here
   13 | char s[N][N];
      |      ^
genetics.cpp:79:11: error: redefinition of 'std::bitset<4104> tmp'
   79 | bitset<N> tmp, a[N], g[N], c[N], t[N];
      |           ^~~
genetics.cpp:14:11: note: 'std::bitset<4104> tmp' previously defined here
   14 | bitset<N> tmp, a[N], g[N], c[N], t[N];
      |           ^~~
genetics.cpp:79:16: error: redefinition of 'std::bitset<4104> a [4104]'
   79 | bitset<N> tmp, a[N], g[N], c[N], t[N];
      |                ^
genetics.cpp:14:16: note: 'std::bitset<4104> a [4104]' previously defined here
   14 | bitset<N> tmp, a[N], g[N], c[N], t[N];
      |                ^
genetics.cpp:79:22: error: redefinition of 'std::bitset<4104> g [4104]'
   79 | bitset<N> tmp, a[N], g[N], c[N], t[N];
      |                      ^
genetics.cpp:14:22: note: 'std::bitset<4104> g [4104]' previously defined here
   14 | bitset<N> tmp, a[N], g[N], c[N], t[N];
      |                      ^
genetics.cpp:79:28: error: redefinition of 'std::bitset<4104> c [4104]'
   79 | bitset<N> tmp, a[N], g[N], c[N], t[N];
      |                            ^
genetics.cpp:14:28: note: 'std::bitset<4104> c [4104]' previously defined here
   14 | bitset<N> tmp, a[N], g[N], c[N], t[N];
      |                            ^
genetics.cpp:79:34: error: redefinition of 'std::bitset<4104> t [4104]'
   79 | bitset<N> tmp, a[N], g[N], c[N], t[N];
      |                                  ^
genetics.cpp:14:34: note: 'std::bitset<4104> t [4104]' previously defined here
   14 | bitset<N> tmp, a[N], g[N], c[N], t[N];
      |                                  ^
genetics.cpp:81:5: error: redefinition of 'int main()'
   81 | int main() {
      |     ^~~~
genetics.cpp:16:5: note: 'int main()' previously defined here
   16 | int main() {
      |     ^~~~
genetics.cpp: In function 'int main()':
genetics.cpp:85:10: warning: unused variable 'AC' [-Wunused-variable]
   85 |     bool AC = true;
      |          ^~