Submission #824332

#TimeUsernameProblemLanguageResultExecution timeMemory
824332lto5Genetics (BOI18_genetics)C++17
0 / 100
36 ms9576 KiB
#include <bits/stdc++.h> using namespace std; mt19937_64 rng(time(NULL)); const int N = 4505; char a[N][N]; int64_t h[N]; int mpp[26]; int64_t rows[N][4]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define task "a" if (fopen(task ".inp", "r")) { freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } int n, m, k; cin >> n >> m >> k; int64_t all_rows = 0; for (int i = 1; i <= n; i++) { h[i] = uniform_int_distribution<int64_t>(1, 1e18)(rng); all_rows += h[i]; } mpp['A'] = 0, mpp['C'] = 1, mpp['T'] = 2, mpp['G'] = 3; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { cin >> a[i][j]; rows[j][mpp[a[i][j]]] += h[i]; } } for (int i = 1; i <= n; i++) { int64_t list_row = 0; for (int j = 1; j <= m; j++) { list_row += all_rows - rows[j][mpp[a[i][j]]]; } if (list_row == (all_rows - h[i]) * k) { cout << i; return 0; } } cout << -1; return 0; } /* list[j, c] = {i : a[i][j] = c} for i = 1 -> n: for j = 1 -> m: c = a[i][j] A = {} for (c' = 0 -> c) if c != c' A.insert(all(list[j, c'])) check if [1, n] appear in A k times */

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:33:25: warning: array subscript has type 'char' [-Wchar-subscripts]
   33 |       rows[j][mpp[a[i][j]]] += h[i];
      |                   ~~~~~~^
genetics.cpp:39:48: warning: array subscript has type 'char' [-Wchar-subscripts]
   39 |       list_row += all_rows - rows[j][mpp[a[i][j]]];
      |                                          ~~~~~~^
genetics.cpp:19:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     freopen(task ".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen(task ".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:29:10: warning: array subscript 65 is above array bounds of 'int [26]' [-Warray-bounds]
   29 |   mpp['A'] = 0, mpp['C'] = 1, mpp['T'] = 2, mpp['G'] = 3;
      |   ~~~~~~~^
genetics.cpp:10:5: note: while referencing 'mpp'
   10 | int mpp[26];
      |     ^~~
genetics.cpp:29:24: warning: array subscript 67 is above array bounds of 'int [26]' [-Warray-bounds]
   29 |   mpp['A'] = 0, mpp['C'] = 1, mpp['T'] = 2, mpp['G'] = 3;
      |                 ~~~~~~~^
genetics.cpp:10:5: note: while referencing 'mpp'
   10 | int mpp[26];
      |     ^~~
genetics.cpp:29:38: warning: array subscript 84 is above array bounds of 'int [26]' [-Warray-bounds]
   29 |   mpp['A'] = 0, mpp['C'] = 1, mpp['T'] = 2, mpp['G'] = 3;
      |                               ~~~~~~~^
genetics.cpp:10:5: note: while referencing 'mpp'
   10 | int mpp[26];
      |     ^~~
genetics.cpp:29:52: warning: array subscript 71 is above array bounds of 'int [26]' [-Warray-bounds]
   29 |   mpp['A'] = 0, mpp['C'] = 1, mpp['T'] = 2, mpp['G'] = 3;
      |                                             ~~~~~~~^
genetics.cpp:10:5: note: while referencing 'mpp'
   10 | int mpp[26];
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...