제출 #676895

#제출 시각아이디문제언어결과실행 시간메모리
676895CyanmondGenetics (BOI18_genetics)C++17
100 / 100
337 ms36416 KiB
#include <bits/stdc++.h> using i64 = long long; constexpr i64 P = (1ll << 61) - 1; void add(i64 &a, i64 b) { a += b; if (a >= P) { a -= P; } } int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); int N, M, K; std::cin >> N >> M >> K; std::vector<std::string> S(N); for (auto &e : S) { std::cin >> e; } std::vector<i64> H(N); std::mt19937 mt(100); std::uniform_int_distribution<i64> dist(0, P - 1); for (auto &e : H) { e = dist(mt); } std::vector<std::array<i64, 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) { i64 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]); } } i64 exp = 0; for (int j = 0; j < N; ++j) { if (i == j) { continue; } add(exp, H[j]); } exp = (i64)(__int128_t(exp) * __int128_t(K) % __int128_t(P)); if (exp == sum) { std::cout << i + 1 << std::endl; break; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...