제출 #554598

#제출 시각아이디문제언어결과실행 시간메모리
554598new_accGenetics (BOI18_genetics)C++14
100 / 100
381 ms67532 KiB
#include<bits/stdc++.h> #define fi first #define se second #define pitem item* using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector<int> vi; typedef vector<ll> vl; const int N=1e6+10; const int SS=1<<19; const int INFi=2e9; const ll INFl=1e13; const ll mod=998244353; const ll mod2=1e9+7; const ll mod3=1000696969; const ll p=70032301; const ull p2=913; const int L=20; string s[N]; int n,m,k; ll nh[N][4],pot[N]; int xd(char a){ if(a=='A') return 0; if(a=='C') return 1; if(a=='G') return 2; return 3; } void solve(){ cin>>n>>m>>k; for(int i=1;i<=n;i++) cin>>s[i]; pot[0]=1; for(int i=1;i<=n;i++) pot[i]=(pot[i-1]*p)%mod; for(int i=1;i<=n;i++) for(int j=0;j<m;j++) nh[j][xd(s[i][j])]+=pot[i]; for(int i=0;i<m;i++) for(int j=0;j<4;j++) nh[i][j]%=mod; ll sum=0; for(int i=1;i<=n;i++) sum+=pot[i]; sum%=mod; for(int i=1;i<=n;i++){ ll aktsum=sum-pot[i]; (aktsum+=mod)%=mod; (aktsum*=(ll)k)%=mod; ll __curr=0; for(int j=0;j<m;j++){ for(int l=0;l<4;l++){ if(xd(s[i][j])==l) continue; __curr+=nh[j][l]; } } __curr%=mod; if(__curr==aktsum){ cout<<i<<"\n"; return; } } } int main(){ ios_base::sync_with_stdio(0),cin.tie(0); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...