제출 #1252943

#제출 시각아이디문제언어결과실행 시간메모리
1252943Semen07Rope (JOI17_rope)C++20
0 / 100
47 ms48448 KiB
#include <bits/stdc++.h> int main() { freopen("main.in", "r", stdin); freopen("main.out", "w", stdout); size_t n, m; std::cin >> n >> m; std::vector<size_t> a(n); for (size_t i = 0; i < n; ++i) { std::cin >> a[i]; --a[i]; } for (size_t f = 0; f < m; ++f) { size_t ans = n; for (size_t s = 0; s < m; ++s) { size_t score0 = 0; for (size_t i = 0; i < n; i += 2) { if (i + 1 < n) { if (a[i] == a[i + 1] && (a[i] == f || a[i] == s)) continue; if (a[i] == f || a[i + 1] == f || a[i] == s || a[i + 1] == s) score0++; else score0 += 2; } else { if (a[i] != f && a[i] != s) score0++; } } size_t score1 = 0; for (size_t i = 0; i < n + 1; i += 2) { if (i > 0 && i < n) { if (a[i] == a[i - 1] && (a[i] == f || a[i] == s)) continue; if (a[i] == f || a[i - 1] == f || a[i] == s || a[i - 1] == s) score1++; else score1 += 2; } else { if (i == n) --i; if (a[i] != f && a[i] != s) score1++; } } ans = std::min({ans, score0, score1}); } std::cout << ans << '\n'; } }

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

rope.cpp: In function 'int main()':
rope.cpp:4:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    4 |     freopen("main.in", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
rope.cpp:5:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    5 |     freopen("main.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...
#Verdict Execution timeMemoryGrader output
Fetching results...