Submission #952787

#TimeUsernameProblemLanguageResultExecution timeMemory
952787badontGenetics (BOI18_genetics)C++17
100 / 100
340 ms102512 KiB
#include <bits/stdc++.h> using namespace std; // clang-format off template <typename T, typename = void> struct is_iterable : false_type {};template <typename T>struct is_iterable< T, void_t<decltype(begin(declval<T>())), decltype(end(declval<T>()))>> : true_type {};template <typename T>typename enable_if<is_iterable<T>::value && !is_same<T, string>::value,ostream &>::type operator<<(ostream &cout, T const &v);template <typename A, typename B>ostream &operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.first << ", " << p.second << ")";}template <typename T>typename enable_if<is_iterable<T>::value && !is_same<T, string>::value, ostream &>::type operator<<(ostream &cout, T const &v) { cout << "["; for (auto it = v.begin(); it != v.end();) {cout << *it; if (++it != v.end()) cout << ", "; } return cout << "]";} #ifdef LOCAL void dbg_out() { cout << endl; } template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); } #define debug(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define debug(...) "zzz" #endif // clang-format on using ll = long long; using ld = long double; using pii = pair<ll, ll>; #define all(x) x.begin(), x.end() #define mp make_pair #define pb push_back #define f first #define s second using hash_t = uint64_t; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); void solve() { // open int n, m, k; cin >> n >> m >> k; vector<hash_t> h(n); for (auto &u : h) u = rng(); hash_t sum = accumulate(all(h), hash_t(0)); vector<string> inp(n); for (auto &row : inp) cin >> row; vector a(n, vector<int>(m, -1)); for (int row = 0; row < n; row++) { for (int col = 0; col < m; col++) { switch (inp[row][col]) { case 'A': a[row][col] = 0; break; case 'G': a[row][col] = 1; break; case 'T': a[row][col] = 2; break; case 'C': a[row][col] = 3; break; } } } vector f(m, vector<hash_t>(4, 0)); for (int i = 0; i < n; i++) { for (int col = 0; col < m; col++) { f[col][a[i][col]] += h[i]; } } for (int cand = 0; cand < n; cand++) { hash_t expected_sum = (sum - h[cand]) * k; hash_t agg_sum = 0; for (int col = 0; col < m; col++) { for (int z = 0; z < 4; z++) { if (z == a[cand][col]) continue; agg_sum += f[col][z]; } } if (agg_sum == expected_sum) { cout << cand + 1 << "\n"; return; } } assert(false); } int main() { cin.tie(0)->sync_with_stdio(false); ll T = 1; // cin >> T; for (int t = 0; t < T; t++) solve(); cout.flush(); 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...