제출 #760798

#제출 시각아이디문제언어결과실행 시간메모리
760798MetalPowerGenetics (BOI18_genetics)C++14
100 / 100
293 ms19828 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int MX = 4105; int N, M, K, wt[MX]; ll sum[MX][4]; string s[MX]; int index(char c){ if(c == 'A') return 0; else if(c == 'C') return 1; else if(c == 'G') return 2; else return 3; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N >> M >> K; for(int i = 0; i < N; i++) cin >> s[i]; random_device rd; mt19937 rng(rd()); uniform_int_distribution<> distrib(1, 1 << 30); ll tot_wt = 0; for(int i = 0; i < N; i++){ wt[i] = distrib(rng); tot_wt += wt[i]; } for(int i = 0; i < N; i++){ for(int j = 0; j < M; j++) sum[j][index(s[i][j])] += wt[i]; } for(int i = 0; i < N; i++){ ll total = 0; for(int j = 0; j < M; j++){ for(int k = 0; k < 4; k++){ if(index(s[i][j]) == k) continue; total += sum[j][k]; } } ll hash = 1ll * K * tot_wt - 1ll * K * wt[i]; if(total == hash){ 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...