Submission #130082

#TimeUsernameProblemLanguageResultExecution timeMemory
130082TadijaSebezGenetics (BOI18_genetics)C++11
100 / 100
1080 ms84476 KiB
#include <stdio.h> #include <stdlib.h> #include <ctime> const int N=4115; int my[N],sz[2],cnt[2][4][N]; char s[N][N]; int val[N][N]; bool ok[N]; int oks; void Try(int n, int m, int k) { int i,j; for(j=1;j<=m;j++) for(i=0;i<4;i++) cnt[0][i][j]=cnt[1][i][j]=0; sz[0]=sz[1]=0; for(i=1;i<=n;i++) { my[i]=rand()&1; sz[my[i]]++; for(j=1;j<=m;j++) cnt[my[i]][val[i][j]][j]++; } for(i=1;i<=n;i++) { if(ok[i]) { int po[2]; po[0]=po[1]=0; for(j=1;j<=m;j++) { po[0]+=sz[0]-cnt[0][val[i][j]][j]; po[1]+=sz[1]-cnt[1][val[i][j]][j]; } sz[my[i]]--; if(po[0]!=sz[0]*k) ok[i]=0,oks--; else if(po[1]!=sz[1]*k) ok[i]=0,oks--; sz[my[i]]++; } } } int main() { srand(time(0)); int n,m,k,i,j; scanf("%i %i %i",&n,&m,&k); for(i=1;i<=n;i++) scanf("%s",s[i]+1),ok[i]=1; for(i=1;i<=n;i++) for(j=1;j<=m;j++) { if(s[i][j]=='A') val[i][j]=0; if(s[i][j]=='C') val[i][j]=1; if(s[i][j]=='G') val[i][j]=2; if(s[i][j]=='T') val[i][j]=3; } oks=n; while(oks>1) Try(n,m,k); int ans=0; for(i=1;i<=n;i++) if(ok[i]) ans=i; printf("%i\n",ans); return 0; }

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i %i",&n,&m,&k);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~
genetics.cpp:44:38: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(i=1;i<=n;i++) scanf("%s",s[i]+1),ok[i]=1;
                    ~~~~~~~~~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...