This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*
Editor: Abdelrahman Hossam
Nickname: Blobo2_Blobo2
IOI next year isA :)
*/
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-funroll-all-loops,-fpeel-loops,-funswitch-loops")
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define endl "\n"
#define all(v) v.begin(),v.end()
#define gen(arr,n,nxt) generate(arr,arr+n,nxt)
#define Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty ios_base::sync_with_stdio(false);cin.tie(0);
#define EPS 0.00000001
const int mo=1e9+7,INF=1e18;
int nxt(){int x;cin>>x;return x;}
int rand(int l, int r){
static mt19937
rng(chrono::steady_clock::now().time_since_epoch().count());
uniform_int_distribution<int> ludo(l, r);
return ludo(rng);
}
signed main(){
Blobo2_el_7akim_elly_3ayz_yro7_IOI_w_3ayz_yakol_jilaty
freopen("in.txt","r",stdin);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n=nxt(),m=nxt(),k=nxt();
string dna[n];
for(int i=0;i<n;i++)cin>>dna[i];
if(n<=1800){
vector<int>v;
for(int i=0;i<n;i++)
v.push_back(i);
while(v.size()>1){
int x = rand(0,v.size()-1);
for(int i=0;i<n;i++){
int ok=0;
if(i == v[x])continue;
for(int j=0;j<m;j++)
ok+= dna[v[x]][j] != dna[i][j];
if(ok != k)
goto tooooooooooooo;
}
cout<<v[x]+1;
return 0;
tooooooooooooo:;
v.erase(v.begin()+x);
}
cout<<v[0]+1;
}
else{
bitset<4100> a[n];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(dna[i][j] == 'A')
a[i][j] =0;
else
a[i][j] =1;
}
}
vector<int>v;
for(int i=0;i<n;i++)
v.push_back(i);
while(v.size()>1){
shuffle(all(v),rng);
for(int i=0;i<n-1;i++){
bitset<4100>ok= (a[v[i]] ^ a[v.back()]);
if(ok.count() != k)
goto toooooooooooo;
}
cout<<v[0]+1;
return 0;
toooooooooooo:;
v.pop_back();
}
cout<<v[0]+1;
}
return 0;
}
Compilation message (stderr)
genetics.cpp:21:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
21 | const int mo=1e9+7,INF=1e18;
| ^~~~
genetics.cpp: In function 'int main()':
genetics.cpp:76:31: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
76 | if(ok.count() != k)
| ~~~~~~~~~~~^~~~
genetics.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
33 | freopen("in.txt","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |