Submission #1105945

#TimeUsernameProblemLanguageResultExecution timeMemory
1105945RiverFlowGenetics (BOI18_genetics)C++14
100 / 100
299 ms36352 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; long long cnt[N][4]; int cv(char c) { if (c == 'A') return 0; if (c == 'C') return 1; if (c == 'G') return 2; return 3; } string s[N]; void main_code() { int n, m, k; cin >> n >> m >> k; srand(time(NULL)); vector<int> v(n + 1, 0); long long sv=0; FOR(i, 1, n) { cin >> s[i]; v[i] = rand() % (INT_MAX - 10); FOR(j, 0, m - 1) { char c = s[i][j]; cnt[j][cv(c)] += v[i]; } sv += v[i]; } vec<int> ch; FOR(i, 1, n) { long long 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 * (sv - v[i])) { ch.push_back(i); } } for(int i : ch) { bool ok=1; FOR(j, 1, n) if (i!=j){ if (ok==0)break; int cx = 0; FOR(t, 0, m - 1){ cx += s[i][t] != s[j][t]; if(cx>k)break; } ok&=(cx==k); } 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...