제출 #870585

#제출 시각아이디문제언어결과실행 시간메모리
870585nguyentunglamGenetics (BOI18_genetics)C++17
100 / 100
595 ms40532 KiB
#include<bits/stdc++.h> #define all(v) v.begin(), v.end() #define endl "\n" using namespace std; const int N = 1e5 + 10, base = 1e5 + 1, mod = 1e9 + 7; int f[N], g[N], p[N]; string s[N]; int32_t main() { #define task "" cin.tie(0) -> sync_with_stdio(0); if (fopen("task.inp", "r")) { freopen("task.inp", "r", stdin); freopen("task.out", "w", stdout); } if (fopen(task".inp", "r")) { freopen (task".inp", "r", stdin); freopen (task".out", "w", stdout); } int n, m, k; cin >> n >> m >> k; p[0] = 1; for(int i = 1; i <= n; i++) { cin >> s[i]; p[i] = 1LL * p[i - 1] * base % mod; } auto add = [&] (int &a, int b) { a += b; if (a >= mod) a -= mod; if (a < 0) a += mod; }; int sum = 0; for(int i = 1; i <= n; i++) add(sum, 1LL * p[i] * k % mod); for(int j = 0; j < m; j++) { int total = 0; for(int i = 1; i <= n; i++) { add(f[int(s[i][j])], p[i]); add(total, p[i]); } for(int i = 1; i <= n; i++) { add(g[i], total); add(g[i], -f[int(s[i][j])]); } for(int i = 1; i <= n; i++) f[int(s[i][j])] = 0; } // for(int i = 1; i <= n; i++) cout << g[i] << endl; for(int i = 1; i <= n; i++) { add(sum, -1LL * p[i] * k % mod); if (g[i] == sum) return cout << i, 0; add(sum, 1LL * p[i] * k % mod); } }

컴파일 시 표준 에러 (stderr) 메시지

genetics.cpp: In function 'int32_t main()':
genetics.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     freopen("task.inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
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.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:23:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |     freopen (task".inp", "r", stdin);
      |     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:24:13: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |     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...