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
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//s.order_of_key(x)
//s.find_by_order(idx)
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);
int n=nxt(),m=nxt(),k=nxt();
ordered_set st;
vector<pair<string,int> >v;
for(int i=0;i<n;i++){
string s;
cin>>s;
st.insert(i);
v.push_back({s,i});
}
while(st.size()>1){
int x = rand(0,st.size()-1);
x = *st.find_by_order (x);
string s = v[x].first;
vector<int>rem;
int idx= 0;
for(auto y:st){
if(y == x)continue;
int c = 0;
for(int j=0;j<m;j++)
c += v[y].first[j] != s[j];
if(c != k){
if(idx == 0)
rem.push_back(x);
rem.push_back(y);
}
idx ++;
}
if(!rem.size()){
cout<<x+1<<endl;
return 0;
}
for(int i=0;i<rem.size();i++){
st.erase(rem[i]);
cout<<rem[i]<<' ';
}
cout<<endl;
}
cout<<(*st.begin())+1;
return 0;
}
Compilation message (stderr)
genetics.cpp:29:24: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
29 | const int mo=1e9+7,INF=1e18;
| ^~~~
genetics.cpp: In function 'int main()':
genetics.cpp:73:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
73 | for(int i=0;i<rem.size();i++){
| ~^~~~~~~~~~~
# | 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... |