Submission #146352

#TimeUsernameProblemLanguageResultExecution timeMemory
146352MvCGenetics (BOI18_genetics)C++14
100 / 100
1463 ms29188 KiB
#pragma GCC target("avx2") #pragma GCC optimization("O3") #pragma GCC optimization("unroll-loops") #include<bits/stdc++.h> //#include "boxes.h" #define rc(x) return cout<<x<<endl,0 #define pb push_back #define mkp make_pair #define in insert #define er erase #define fd find #define fr first #define sc second typedef long long ll; typedef long double ld; const ll INF=0x3f3f3f3f3f3f3f3f; const ll llinf=(1LL<<62); const int inf=(1<<30); const int nmax=5e3+50; const int mod=1e9+7; using namespace std; int n,m,k,i,j,bl,nr,t,x,y,c[4][nmax]; char a[nmax][nmax]; bitset<4105>b[4][nmax]; vector<int>rad,rid; int main() { //freopen("sol.in","r",stdin); //freopen("sol.out","w",stdout); mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0); cin>>n>>m>>k; for(i=1;i<=n;i++)for(j=1;j<=m;j++)cin>>a[i][j]; for(i=1;i<=n;i++) { for(j=1;j<=m;j++) { if(a[i][j]=='A') { c[0][j]++; b[0][i][j]=1; } else if(a[i][j]=='C') { c[1][j]++; b[1][i][j]=1; } else if(a[i][j]=='G') { c[2][j]++; b[2][i][j]=1; } else if(a[i][j]=='T') { c[3][j]++; b[3][i][j]=1; } } } for(i=1;i<=n;i++) { nr=0; for(j=1;j<=m;j++) { if(a[i][j]=='A')nr+=n-c[0][j]; else if(a[i][j]=='C')nr+=n-c[1][j]; else if(a[i][j]=='G')nr+=n-c[2][j]; else nr+=n-c[3][j]; } if(nr==k*(n-1))rid.pb(i); } for(i=1;i<=n;i++)rad.pb(i); shuffle(rad.begin(),rad.end(),rng); shuffle(rid.begin(),rid.end(),rng); for(i=0;i<rid.size();i++) { x=rid[i]; bl=0; for(j=0;j<n;j++) { y=rad[j]; if(x==y)continue; nr=0; for(t=0;t<4;t++)nr+=(b[t][x]^b[t][y]).count(); nr/=2; if(nr!=k) { bl=1; break; } } if(!bl)rc(x); } return 0; }

Compilation message (stderr)

genetics.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
genetics.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
 
genetics.cpp: In function 'int main()':
genetics.cpp:75:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(i=0;i<rid.size();i++)
          ~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...