제출 #824333

#제출 시각아이디문제언어결과실행 시간메모리
824333lto5Genetics (BOI18_genetics)C++14
100 / 100
256 ms35020 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[256]; 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 */

컴파일 시 표준 에러 (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);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...