Submission #1067983

#TimeUsernameProblemLanguageResultExecution timeMemory
1067983thinknoexitArchery (IOI09_archery)C++17
10 / 100
2095 ms604 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; const int N = 404; int a[2 * N]; int val[N][2]; int mx[N]; int n, r, rnk; int cal() { for (int i = 0;i < n;i++) { val[i][0] = min(a[2 * i], a[2 * i + 1]); val[i][1] = max(a[2 * i], a[2 * i + 1]); } bool ch = 0; int nowr = r; for (int _ = 1;_ <= n * n && nowr;_++) { ch = 0; for (int i = 0;i < n;i++) { if (i == 0) swap(val[i][0], val[i][1]); mx[i] = val[i][0]; } for (int i = 0;i < n;i++) { val[i][0] = mx[(i + 1) % n]; if (val[i][0] > val[i][1]) swap(val[i][0], val[i][1]); } nowr--; } for (int i = 0;i < n;i++) if (val[i][0] == rnk || val[i][1] == rnk) return (i + nowr) % n; return -1; } int main() { cin.tie(nullptr)->sync_with_stdio(false); cin >> n >> r; for (int i = 0;i < 2 * n;i++) cin >> a[i]; rnk = a[0]; int mn = n, idx = -1; for (int i = 0;i < 2 * n;i += 2) { if (i) swap(a[i], a[i - 2]); int val = cal(); if (val <= mn) { mn = val; idx = i / 2; } } cout << idx + 1 << '\n'; return 0; } /* 7 4 2 6 5 8 1 3 */

Compilation message (stderr)

archery.cpp: In function 'int cal()':
archery.cpp:14:10: warning: variable 'ch' set but not used [-Wunused-but-set-variable]
   14 |     bool ch = 0;
      |          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...