Submission #532698

#TimeUsernameProblemLanguageResultExecution timeMemory
532698fatemetmhrGenetics (BOI18_genetics)C++17
19 / 100
2062 ms13868 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define pb push_back mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); const int maxn5 = 5e3 + 10; string s; bitset <4105> a[maxn5], tmp; int av[maxn5], per[maxn5]; int n, m, k, sz; inline bool ok(int i, int j){ tmp = a[i] ^ a[j]; //cout << i << ' ' << j << ' ' << tmp.count() << endl; return tmp.count() == k; } inline void rem(int v){ //cout << "removing " << v << endl; bool re = false; for(int i = 0; i < sz; i++){ if(re) per[i - 1] = per[i]; if(per[i] == v) re = true; } if(re) sz--; //cout << sz << endl; } inline void check(int v){ for(int i = 0; i < n; i++) av[i] = i; shuffle(av, av + n, rng); for(int i = 0; i < n; i++) if(v != av[i] && !ok(v, av[i])){ rem(av[i]); return; } cout << v + 1 << endl; exit(0); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m >> k; for(int i = 0; i < n; i++){ cin >> s; for(int j = 0; j < m; j++) if(s[j] == 'A') a[i][j] = 1; per[i] = i; } sz = n; while(true){ int v = per[rng() % sz]; check(v); rem(v); } }

Compilation message (stderr)

genetics.cpp: In function 'bool ok(int, int)':
genetics.cpp:23:21: warning: comparison of integer expressions of different signedness: 'std::size_t' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   23 |  return tmp.count() == k;
      |         ~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...