제출 #1197060

#제출 시각아이디문제언어결과실행 시간메모리
119706012345678Genetics (BOI18_genetics)C++20
100 / 100
1105 ms20676 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long mt19937 rng(12345678); const ll nx=4105, mod=1e9+7; ll n, m, k, mp[100]; string s[nx]; struct hash { ll w[nx], qs[nx][4], sm, target; void init() { for (int i=0; i<n; i++) w[i]=(rng()%(mod-1))+1, sm+=w[i]; for (int i=0; i<n; i++) for (int j=0; j<m; j++) qs[j][mp[s[i][j]]]=(qs[j][mp[s[i][j]]]+w[i])%mod; } bool valid(int idx) { target=0; for (int i=0; i<m; i++) for (int j=0; j<4; j++) if (j!=mp[s[idx][i]]) target=(target+qs[i][j])%mod; return target==(((((sm-w[idx])%mod+mod)%mod)*k)%mod); } } h[5]; int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>m>>k; mp['A']=0, mp['C']=1, mp['T']=2, mp['G']=3; for (int i=0; i<n; i++) cin>>s[i]; for (int i=0; i<5; i++) h[i].init(); for (int i=0; i<n; i++) { bool f=1; for (int j=0; j<5; j++) if (!h[j].valid(i)) f=0; if (f) return cout<<i+1, 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...