제출 #252337

#제출 시각아이디문제언어결과실행 시간메모리
252337SamAndArchery (IOI09_archery)C++17
19 / 100
2097 ms7672 KiB
#include <bits/stdc++.h> using namespace std; #define m_p make_pair const int N = 400005; int n, r; int a[N]; pair<int, int> b[N], bb[N]; void solv1() { int ans1 = N, ans2; for (int u = n; u >= 1; --u) { int k = 0; for (int i = 2; i < u * 2; i += 2) b[++k] = m_p(a[i], a[i + 1]); b[++k] = m_p(0, a[u * 2]); for (int i = u * 2 + 1; i <= n * 2; i += 2) b[++k] = m_p(a[i], a[i + 1]); for (int j = 1; j <= 2 * n; ++j) { for (int i = 1; i <= n; ++i) { if (b[i].first > b[i].second) { if (i == 1) { bb[i].second = b[i].first; bb[n].first = b[i].second; } else { bb[i - 1].first = b[i].first; bb[i].second = b[i].second; } } else { if (i == 1) { bb[i].second = b[i].second; bb[n].first = b[i].first; } else { bb[i - 1].first = b[i].second; bb[i].second = b[i].first; } } } for (int i = 1; i <= n; ++i) b[i] = bb[i]; } int t = 0; for (int i = 1; i <= n; ++i) { if (b[i].second == 0) { t = i; break; } } if (!t) { for (int i = 1; i <= n; ++i) { if (b[i].first == 0) { t = (i - 1 - (r - n * 2) % n + n) % n; ++t; break; } } } if (t < ans1) { ans1 = t; ans2 = u; } if (ans1 == 1) break; } printf("%d\n", ans2); } int main() { scanf("%d%d", &n, &r); for (int i = 1; i <= n * 2; ++i) scanf("%d", &a[i]); if (a[1] == 1) { printf("%d\n", n * 2); return 0; } if (a[1] == n * 2) { printf("%d\n", 2); return 0; } for (int i = 2; i <= n * 2; ++i) { if (a[i] < a[1]) a[i] = 1; else a[i] = -1; } a[1] = 0; solv1(); return 0; }

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

archery.cpp: In function 'int main()':
archery.cpp:90:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d", &n, &r);
     ~~~~~^~~~~~~~~~~~~~~~
archery.cpp:92:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &a[i]);
         ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...