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;
int main() {
cin.tie(0)->sync_with_stdio(0);
int n,rd;
cin>>n>>rd;
rd-= 2*n;
int skill;
cin>>skill;
vector<int> vi;
for(int i =0 ;i < 2*n-1;i++) {
int x;
cin>>x;
vi.push_back(x);
}
vector<int> contest[200];
for(int i = 0; i < n;i++)
contest[i] = vector<int>(2);
int minplace = 1e9,maxst = 0;
for(int i = 0; i < 2*n;i++)
{
vector<int> vi2(vi);
vi2.insert(vi2.begin() + i,skill);
for(int j =0; j < n;j++)
contest[j][0] = vi2[j*2],contest[j][1] = vi2[j*2 + 1];
for(int k = 0 ;k < n * 2;k++) {
vector<int> contest2[200];
for(int j =0 ; j < n;j++) {
if(contest[j][0]>contest[j][1])
swap(contest[j][0], contest[j][1]);
if(j==0) {
contest2[j].push_back(contest[j][0]);
contest2[n-1].push_back(contest[j][1]);
} else {
contest2[j].push_back(contest[j][1]);
contest2[j-1].push_back(contest[j][0]);
}
}
// for(int j = 0; j < n;j++)
// cout<<contest2[j][0]<<" "<<contest2[j][1]<<" ";
// cout<<"\n";
for(int j = 0; j < n;j++)
contest[j] = contest2[j];
}
for(int j = 0; j < n;j++)
if(contest[j][0] > contest[j][1])
swap(contest[j][0],contest[j][1]);
int in;
for(int j =0 ; j < n;j++)
if(contest[j][0] == skill || contest[j][1] == skill)
in = j;
int endup;
if(skill ==1 || skill > n ){
endup = in;
} else {
endup = (in - rd %n + n) % n;
}
// cout<<i<<" "<<endup<<"\n";
if(endup <= minplace) {
maxst = i/2 + 1;
minplace = endup;
}
}
cout<<maxst<<"\n";
}
Compilation message (stderr)
archery.cpp: In function 'int main()':
archery.cpp:64:19: warning: 'in' may be used uninitialized in this function [-Wmaybe-uninitialized]
64 | endup = (in - rd %n + n) % n;
| ~~~^~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |