Submission #270456

#TimeUsernameProblemLanguageResultExecution timeMemory
270456gs14004Archery (IOI09_archery)C++17
20 / 100
2095 ms1024 KiB
#include <bits/stdc++.h> #define sz(v) ((int)(v).size()) #define all(v) (v).begin(), (v).end() using namespace std; using lint = long long; using pi = pair<int, int>; const int MAXN = 10005; const int mod = 1e9 + 7; int n, r, a[MAXN], b[MAXN]; int Do(int r, int s){ for(int i=0; i<r; i++){ for(int j=0; j<n; j++){ if(a[j] > a[j+n]) swap(a[j], a[j+n]); } swap(a[0], a[n]); rotate(a, a + 1, a + n); } int pos = (find(a, a + 2 * n, s) - a); return pos % n; } int main(){ scanf("%d %d",&n,&r); for(int i=0; i<2*n; i++){ scanf("%d",&b[i]); } r = (r % (2 * n)) + 2 * n; pi ret(1e9, 1e9); for(int i=0; i<n; i++){ vector<int> foo(b, b + 2 * n); rotate(foo.begin(), foo.begin() + 1, foo.begin() + 2 * i + 1); for(int i=0; i<n; i++){ a[i] = foo[2*i]; a[i+n] = foo[2*i+1]; } ret = min(ret, pi(Do(r, b[0]), -i)); } cout << 1-ret.second << endl; }

Compilation message (stderr)

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