Submission #554592

#TimeUsernameProblemLanguageResultExecution timeMemory
554592new_accGenetics (BOI18_genetics)C++14
0 / 100
33 ms36912 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 mod2=998244353; const ll mod=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; bitset<N>ok; bool check(int a){ bool res=1; for(int i=1;i<=n;i++){ if(a==i) continue; int il=0; for(int j=0;j<m;j++) if(s[i][j]!=s[a][j]) il++; if(il!=k) res=0; } return res; } void solve(){ cin>>n>>m>>k; for(int i=1;i<=n;i++) cin>>s[i]; if(check(1)){ cout<<1<<"\n"; return; } int p=0; for(int i=2;i<=n;i++){ int il=0; for(int j=0;j<m;j++) if(s[i][j]!=s[1][j]) il++; if(il==k) ok[i]=1,p=i;; } if(check(p)){ cout<<p<<"\n"; return; } vi kand; for(int i=2;i<p;i++){ int il=0; for(int j=0;j<m;j++) if(s[i][j]!=s[p][j]) il++; if(il==k and ok[i]) kand.push_back(i); } if(kand.size()==2){ if(check(kand[0])) cout<<kand[0]<<"\n"; else cout<<kand[1]<<"\n"; return; } if(kand.size()==1){ cout<<kand[0]<<"\n"; return; } if(s[kand[0]]!=s[kand[1]]){ if(s[kand[1]]==s[kand[2]]) cout<<kand[0]<<"\n"; else cout<<kand[1]<<"\n"; return; } for(int i=1;i<kand.size();i++){ if(s[kand[i]]!=s[kand[0]]){ cout<<kand[i]<<"\n"; return; } } } int main(){ ios_base::sync_with_stdio(0),cin.tie(0); solve(); }

Compilation message (stderr)

genetics.cpp: In function 'void solve()':
genetics.cpp:70:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |  for(int i=1;i<kand.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...