제출 #757961

#제출 시각아이디문제언어결과실행 시간메모리
757961LeSonnnGenetics (BOI18_genetics)C++17
100 / 100
346 ms36396 KiB
#include <bits/stdc++.h> #define task "TXKCK" using namespace std; //typedef long long int64_t; const int64_t oo = (1ll << 61) - 1; int n, m, k; void add(int64_t &a, int64_t b) { a += b; if (a >= oo) { a -= oo; } } void progress() { //cout << oo << " "; cin >> n >> m >> k; vector<std::string> S(n); for (auto &e : S) { cin >> e; } vector<int64_t> H(n); mt19937 mt(100); uniform_int_distribution<int64_t> dist(0, oo - 1); for (auto &e : H) { e = dist(mt); } vector<std::array<int64_t, 4>> hl(m, {0, 0, 0, 0}); auto get_id = [&](char x) { if (x == 'A') return 0; if (x == 'C') return 1; if (x == 'G') return 2; return 3; }; for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { add(hl[j][get_id(S[i][j])], H[i]); } } for (int i = 0; i < n; ++i) { int64_t sum(0); for (int j = 0; j < m; ++j) { const int v = get_id(S[i][j]); for (int x = 0; x < 4; ++x) { if (x == v) { continue; } add(sum, hl[j][x]); } } int64_t expr(0); for (int j = 0; j < n; ++j) { if (i == j) { continue; } add(expr, H[j]); } expr = (int64_t)(__int128_t(expr) * __int128_t(k) % __int128_t(oo)); if (expr == sum) { cout << i + 1 << '\n'; break; } } } // main int main() { // Written by Shyn_ ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); if (fopen(task ".inp", "r")) { freopen(task ".inp", "r", stdin); freopen(task ".out", "w", stdout); } int64_t nt = 1; // cin >> nt; for (; nt--;) { progress(); } } /** LeSonnn_ **/ /** LCG **/

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

genetics.cpp: In function 'int main()':
genetics.cpp:100:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  100 |         freopen(task ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:101:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  101 |         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...