제출 #1068035

#제출 시각아이디문제언어결과실행 시간메모리
106803512345678Archery (IOI09_archery)C++17
20 / 100
113 ms1460 KiB
#include <bits/stdc++.h> using namespace std; const int nx=5005; mt19937 rng(time(0)); int n, r, res=INT_MAX, st; vector<int> p(2*nx), pw(2*nx), npw(2*nx); int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n>>r; r=(r%n)+2*n; for (int i=0; i<2*n; i++) cin>>p[i]; if (n>200) return cout<<(((rng()%n)+n)%n+1), 0; for (int i=0; i<2*n; i+=2) { pw[i]=p[0]; for (int j=0; j<i; j++) pw[j]=p[j+1]; for (int j=i+1; j<2*n; j++) pw[j]=p[j]; for (int t=0; t<r; t++) { for (int j=2; j<2*n; j+=2) { if (pw[j]<pw[j+1]) npw[j-2]=pw[j], npw[j+1]=pw[j+1]; else npw[j-2]=pw[j+1], npw[j+1]=pw[j]; } if (pw[0]<pw[1]) npw[1]=pw[0], npw[2*(n-1)]=pw[1]; else npw[1]=pw[1], npw[2*(n-1)]=pw[0]; pw=npw; } for (int j=0; j<2*n; j++) { if (pw[j]==p[0]) { if (j/2<=res) res=j/2, st=(i/2)+1; } } } cout<<st; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...