Submission #473711

#TimeUsernameProblemLanguageResultExecution timeMemory
473711Sarah_MokhtarGenetics (BOI18_genetics)C++14
46 / 100
461 ms29544 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define read freopen("acpc.in","r",stdin); #define LESSGO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); const ll N=1801,M=505,OO=1e16,mod=1e9+9; int n,m,d,onB[N],offB[N],dis[N]; string a[N]; int solve(){ for(int i=0;i<n;++i){ int cnt=0; for(int j=0;j<n;++j){ if(i==j) continue; int diff=0; for(int k=0;k<m;++k){ if(a[i][k]!=a[j][k]) ++diff; } if(diff==d) ++cnt; } if(cnt==n-1) return i+1; } return 0; } int main(){ cin>>n>>m>>d; for(int i=0;i<n;++i) cin>>a[i]; if(n<=100){ cout<<solve()<<"\n"; return 0; } bitset<N>s[N]; for(int i=0;i<n;++i){ for(int j=0;j<m;++j){ if(a[i][j]=='A') s[i][j]=1; } } for(int i=0;i<n;++i){ int cnt=0; for(int j=0;j<n;++j){ if(i==j) continue; bitset<N>tmp=(s[i]^s[j]); if(tmp.count()==d) ++cnt; } if(cnt==n-1){ cout<<i+1<<"\n"; return 0; } } }

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:43:27: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   43 |             if(tmp.count()==d) ++cnt;
      |                ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...