Submission #1105934

#TimeUsernameProblemLanguageResultExecution timeMemory
1105934RiverFlowGenetics (BOI18_genetics)C++14
46 / 100
2057 ms98192 KiB
#include <bits/stdc++.h> #define nl "\n" #define no "NO" #define yes "YES" #define fi first #define se second #define vec vector #define task "main" #define _mp make_pair #define ii pair<int, int> #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define evoid(val) return void(std::cout << val) #define FOR(i, a, b) for(int i = (a); i <= (b); ++i) #define FOD(i, b, a) for(int i = (b); i >= (a); --i) #define unq(x) sort(all(x)); x.resize(unique(all(x)) - x.begin()) using namespace std; template<typename U, typename V> bool maxi(U &a, V b) { if (a < b) { a = b; return 1; } return 0; } template<typename U, typename V> bool mini(U &a, V b) { if (a > b) { a = b; return 1; } return 0; } const int mod = (int)1e9 + 7; void prepare(); void main_code(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } const bool MULTITEST = 0; prepare(); int num_test = 1; if (MULTITEST) cin >> num_test; while (num_test--) { main_code(); } } void prepare() {}; const int N = (int)4100 + 9; int cnt[N][4]; int cv(char c) { if (c == 'A') return 0; if (c == 'C') return 1; if (c == 'G') return 2; return 3; } int rel[N][N]; string s[N]; void main_code() { int n, m, k; cin >> n >> m >> k; FOR(i, 1, n) { cin >> s[i]; FOR(j, 0, m - 1) { char c = s[i][j]; ++cnt[j][cv(c)]; } } memset(rel, -1, sizeof rel); FOR(i, 1, n) { int sum = 0; FOR(j, 0, m - 1) { int t = cv(s[i][j]); FOR(l, 0, 3) if (l != t) sum += cnt[j][l]; } if (sum == k * (n - 1)) { bool ok = 1; for(int j = 1; j <= n and ok; ++j) if (i != j) { if (rel[i][j] != -1) { ok &= rel[i][j]; } rel[i][j] = 0; int cx = 0; FOR(t, 0, m - 1) cx += s[i][t] != s[j][t]; rel[i][j]=rel[j][i]=(cx==k); ok&=rel[i][j]; } if(ok) evoid(i); } } } /* Let the river flows naturally */

Compilation message (stderr)

genetics.cpp: In function 'int main()':
genetics.cpp:35:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:36:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...