제출 #989071

#제출 시각아이디문제언어결과실행 시간메모리
989071mraronGenetics (BOI18_genetics)C++14
100 / 100
401 ms36748 KiB
#include<iostream> #include<vector> #include<map> #include<set> #include<cassert> #include<unordered_map> #include<unordered_set> #include<functional> #include<queue> #include<stack> #include<cstring> #include<algorithm> #include<cmath> #include<sstream> #include<iomanip> #include<cstdio> #include<cstdlib> #include<numeric> #include<random> #include<chrono> #include<bitset> //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_ds/tree_policy.hpp> using namespace std; //using namespace __gnu_pbds; #define all(x) (x).begin(), (x).end() #define pb push_back #define eb emplace_back #define xx first #define yy second #define sz(x) (int)(x).size() #define gc getchar #define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #define mp make_pair #define ins insert #define chkmn(x,y) (x)=min((x), (y)) #define chkmx(x,y) (x)=max((x), (y)) #define rep(i,a,b) for(int i=a;i<b;i++) #ifndef ONLINE_JUDGE # define LOG(x) (cerr << #x << " = " << (x) << endl) #else # define LOG(x) ((void)0) #endif using ll = long long; using ull = unsigned long long ; using ld = long double ; using str = string; //using ordered_set=tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update>; const double PI=acos(-1); const ll INF = 1LL<<62; const ll MINF = -(1LL<<62); template<typename T> T getint() { T val=0; char c; bool neg=false; while((c=gc()) && !(c>='0' && c<='9')) { neg|=c=='-'; } do { val=(val*10)+c-'0'; } while((c=gc()) && (c>='0' && c<='9')); return val*(neg?-1:1); } //mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng) //CERC 2022F???? int conv(char c) { if(c=='A') return 0; if(c=='G') return 1; if(c=='C') return 2; if(c=='T') return 3; assert(0); } int main() { IO; int n,m,k; cin>>n>>m>>k; array<ll,2> mul={3,5}, p={1,1}; array<ll,2> mod={(ll)1e9+7, (ll)1e9+9}; vector<array<array<ll,2>,4>> col(m); vector<string> s(n); array<ll,2> want{}; for(int i=0;i<n;++i) { cin>>s[i]; for(int j=0;j<m;++j) { int curr=conv(s[i][j]); for(int k=0;k<4;++k) { if(k!=curr) for(int l=0;l<2;++l) { (col[j][k][l]+=p[l])%=mod[l]; } } } for(int l=0;l<2;++l) (want[l]+=p[l]*k)%=mod[l]; for(int l=0;l<2;++l) (p[l]*=mul[l])%=mod[l]; } //~ LOG(want[0]); //~ LOG(want[1]); p={1,1}; for(int i=0;i<n;++i) { array<ll,2> sum{}; for(int j=0;j<m;++j) { int curr=conv(s[i][j]); for(int l=0;l<2;++l) (sum[l]+=col[j][curr][l])%=mod[l]; } //~ LOG(sum[0]); //~ LOG(sum[1]); bool ok=true; for(int l=0;l<2;++l) { ok&=(want[l]-k*p[l]-sum[l])%mod[l]==0; } if(ok) { cout<<i+1<<"\n"; return 0; } for(int l=0;l<2;++l) (p[l]*=mul[l])%=mod[l]; } assert(0); 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...