제출 #961292

#제출 시각아이디문제언어결과실행 시간메모리
961292mgchGenetics (BOI18_genetics)C++14
27 / 100
2029 ms12124 KiB
#include <bits/stdc++.h> using namespace std; const int N = 4107, L = 26, K = 66, MOD = 1000000007; char s[N][N]; int main() { // freopen("input.txt", "r", stdin); // ios::sync_with_stdio(false); cin.tie(0); int n, m, k; scanf("%d%d%d\n", &n, &m, &k); vector <int> ord(n), rnk(n, 0); iota(ord.begin(), ord.end(), 0); for (int i = 0; i < n; ++i) { scanf("%s\n", s[i]); } auto diff = [&](int x, int y) { int ans = 0; for (int i = 0; i < m; ++i) { ans += s[x][i] != s[y][i]; } return ans; }; for (int it = 0; it < K; ++it) { for (int i = 0; i + 1 < (int)ord.size(); ++i) { if (diff(ord[i], ord[i + 1]) != k) { ++i; continue; } rnk[ord[i]] += 1; rnk[ord[i + 1]] += 1; } sort(ord.begin(), ord.end(), [&](int x, int y) { return rnk[x] > rnk[y]; }); while (ord.size() > 1 && rnk[ord.back()] == 0) ord.pop_back(); random_shuffle(ord.begin(), ord.end()); } sort(ord.begin(), ord.end(), [&](int x, int y) { return rnk[x] > rnk[y]; }); for (int j = 0; j < (int)ord.size(); ++j) { int x = ord[j]; bool ok = true; for (int i = 0; i < n && ok; ++i) { if (i == x) continue; if (diff(x, i) != k) ok = false; } if (ok) { cout << x + 1 << '\n'; break; } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

genetics.cpp: In function 'int main()':
genetics.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d%d%d\n", &n, &m, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
genetics.cpp:17:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         scanf("%s\n", s[i]);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...