제출 #1313982

#제출 시각아이디문제언어결과실행 시간메모리
1313982hectormedranoArchery (IOI09_archery)C++20
17 / 100
2096 ms131072 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; struct ans{ ll F, I; }; bool operator <(ans x, ans y){ if(x.F != y.F){return (x.F > y.F);} return (x.I < y.I); } ll N, R; ll FA(vector<ll> t, ll pos, ll nit){ if(pos == 0){return 0;} if(nit == 2*N){ if(pos > N){return t[pos];} return (2*N + t[pos]-(R-nit))%(N); } vector<ll> val(N, -1); for(ll i=0;i<2*N;i++){ if(val[t[i]] == -1){ val[t[i]] = i; continue; } if(t[i] != 0){ t[min(val[t[i]], i)]--; } else { t[max(val[t[i]], i)] = N-1; } } return FA(t, pos, nit+1); } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); ll P; cin>>N>>R>>P; P--; vector<ll> a(2*N-1), t(2*N); for(ll i=0;i<2*N-1;i++){ cin>>a[i]; a[i]--; } ans A; A.F = N; for(ll i=0;i<N;i++){ for(ll j=0;j<i;j++){ t[a[2*j]] = t[a[2*j+1]] = j; } t[P] = t[a[2*i]] = i; for(ll j=i+1;j<N;j++){ t[a[2*j-1]] = t[a[2*j]] =j; } ans B; B.I = i; B.F = FA(t, P, 0); //cout<<FA(t, P, 0)+1<<endl; //if(A < B){cout<<"meow"<<endl;} A = max(A, B); } cout<<A.I+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...