Submission #566305

#TimeUsernameProblemLanguageResultExecution timeMemory
566305minhcoolGenetics (BOI18_genetics)C++17
100 / 100
1397 ms146580 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define fi first #define se second #define pb push_back #define mp make_pair #define foru(i, l, r) for(int i = l; i <= r; i++) #define ford(i, r, l) for(int i = r; i >= l; i--) typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef pair<ii, ii> iiii; const int N = 4505; const int oo = 1e18 + 7, mod = 1e9 + 7; int n, m, K; int a[N][N]; int ha[256]; int tol[N]; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rnd(int l, int r){ int temp = rng() % (r - l + 1); temp = (temp + (r - l + 1)) % (r - l + 1); return temp + l; } int cntt[N][5]; bool ok[N]; int temp[N]; void process(){ ha[0] = 1, ha[6] = 2, ha['T' - 'A'] = 3, ha[2] = 4; cin >> n >> m >> K; //cout << n << " " << m << " " << K << "\n"; for(int i = 1; i <= n; i++){ for(int j = 1; j <= m; j++){ char c; cin >> c; a[i][j] = ha[c - 'A']; //cout << a[i][j] << "\n"; } } int rem = n, itr = 0; while(1){ //itr++; //cout << rem << "\n"; //if(itr == 1000) break; int cnt = 0; for(int i = 1; i <= m; i++){ for(int j = 1; j <= 4; j++) cntt[i][j] = 0; } for(int i = 1; i <= n; i++){ temp[i] = rnd(0, 1); if(temp[i]){ cnt++; for(int j = 1; j <= m; j++) cntt[j][a[i][j]]++; } } for(int i = 1; i <= n; i++){ if(temp[i]) continue; if(ok[i]) continue; int sum = 0; for(int j = 1; j <= m; j++) sum += cntt[j][a[i][j]]; if(sum != cnt * (m - K)){ rem--; ok[i] = 1; } } //cout << rem << "\n"; if(rem == 1) break; } //for(int i = 1; i <= n; i++) cout << ok[i]; for(int i = 1; i <= n; i++) if(!ok[i]) cout << i << "\n"; //int cnt = 0; } signed main(){ ios_base::sync_with_stdio(0); process(); }

Compilation message (stderr)

genetics.cpp: In function 'void process()':
genetics.cpp:52:15: warning: unused variable 'itr' [-Wunused-variable]
   52 |  int rem = n, itr = 0;
      |               ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...