Submission #848276

#TimeUsernameProblemLanguageResultExecution timeMemory
848276ThegeekKnight16Genetics (BOI18_genetics)C++17
100 / 100
170 ms37256 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ll N, M, K; cin >> N >> M >> K; vector<array<ll, 26>> freq(M); vector<ll> v(N), freqTot(M); vector<string> dnas(N); for (auto &s : dnas) cin >> s; for (auto &x : v) x = (rng() % ((ll)1e9 + 10LL)); for (int i = 0; i < N; i++) { const auto &s = dnas[i]; for (int j = 0; s[j]; j++) { freq[j][s[j] - 'A'] += v[i]; freqTot[j] += v[i]; } } ll soma = accumulate(v.begin(), v.end(), 0LL); for (int i = 0; i < N; i++) { ll atual = 0; const auto &s = dnas[i]; for (int j = 0; s[j]; j++) atual += freqTot[j] - freq[j][s[j]-'A']; if (atual == (K * (soma - v[i]))) {cout << i+1 << '\n'; return 0;} } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...