# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
988934 | PenguinsAreCute | Archery (IOI09_archery) | C++17 | 2102 ms | 9040 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
vector<int> comp_pos(int N, int R, vector<int> A) {
R=2*N+(R%N);
for(int i=0;i<R;i++) {
for(int j=0;j<N;j++) if(A[j<<1]>A[j<<1|1]) swap(A[j<<1],A[j<<1|1]);
int wtf = A[1];
A[1] = A[2];
for(int i=2;i<2*N-2;i+=2) A[i]=A[i+2];
A[2*N-2]=wtf;
}
return A;
}
main() {
int N, R; cin >> N >> R;
vector<int> A(2*N); for(int i=0;i<2*N;i++) cin>>A[i];
pair<int,int> best = {5e5,0};
for(int i=1;i<2*N;i++) {
swap(A[i-1],A[i]);
vector<int> u = comp_pos(N,R,A);
for(int j=0;j<2*N;j++) if(u[j]==A[i]) best=min(best,{j>>1,-(i>>1)});
}
cout << 1-best.second;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |