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")
#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 int __int16_t
#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);
}
bitset<4100>ok;
bitset<4100> a[4100];
vector<int>good,all;
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];
bool hacheck_keda_7aga_bas = 0;
for(int i=0;i<n;i++){
cin>>dna[i];
hacheck_keda_7aga_bas |= count(all(dna[i]),'G');
hacheck_keda_7aga_bas |= count(all(dna[i]),'T');
}
if(hacheck_keda_7aga_bas){
for(int i=0;i<n;i++)
good.push_back(i),all.push_back(i);
while(good.size()>1){
shuffle(all(good),rng);
shuffle(all(all),rng);
for(int i=0;i<all.size();i++){
if(good.back() == all[i])continue;
int ok=0;
for(int a=0;a<m;a++)
ok += (dna[all[i]][a] != dna[good.back()][a]);
if(ok != k)
goto tooooooooooo;
}
cout<<good.back()+1;
return 0;
tooooooooooo:;
good.pop_back();
}
cout<<good[0]+1;
}
else{
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;
}
}
for(int i=0;i<n;i++)
good.push_back(i),all.push_back(i);
while(good.size()>1){
shuffle(all(good),rng);
shuffle(all(all),rng);
for(int i=0;i<all.size();i++){
if(good.back() == all[i])continue;
ok = (a[all[i]] ^ a[good.back()]);
if(ok.count() != k)
goto toooooooooooo;
}
cout<<good.back()+1;
return 0;
toooooooooooo:;
good.pop_back();
}
cout<<good[0]+1;
}
return 0;
}
Compilation message (stderr)
genetics.cpp:22:17: warning: overflow in conversion from 'double' to '__int16_t' {aka 'short int'} changes value from '1.000000007e+9' to '32767' [-Woverflow]
22 | const int mo=1e9+7,INF=1e18;
| ~~~^~
genetics.cpp:22:24: warning: overflow in conversion from 'double' to '__int16_t' {aka 'short int'} changes value from '1.0e+18' to '32767' [-Woverflow]
22 | const int mo=1e9+7,INF=1e18;
| ^~~~
genetics.cpp: In function 'int main()':
genetics.cpp:52:26: warning: comparison of integer expressions of different signedness: '__int16_t' {aka 'short int'} and 'std::vector<short int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | for(int i=0;i<all.size();i++){
| ~^~~~~~~~~~~
genetics.cpp:81:26: warning: comparison of integer expressions of different signedness: '__int16_t' {aka 'short int'} and 'std::vector<short int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
81 | for(int i=0;i<all.size();i++){
| ~^~~~~~~~~~~
genetics.cpp:84:31: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and '__int16_t' {aka 'short int'} [-Wsign-compare]
84 | if(ok.count() != k)
| ~~~~~~~~~~~^~~~
# | 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... |