#include<bits/stdc++.h>
using namespace std;
void nextthingy(vector<int> &v){
for(int i=0;i<v.size();i+=2)
if(v[i]>v[i+1])
swap(v[i],v[i+1]);
swap(v[0],v[1]);
for(int i=2;i<v.size();i+=2)
swap(v[i],v[i-2]);
}
int main(){
int n,r;
cin>>n>>r;
r=r%n+n+n;
if(n>500) return cout<<n,0;
vector<int>v(2*n);
for(auto&i:v)cin>>i;
int YOU=v[0];
int bst1=n,bst2;
for(int i=0;i<n;i++){
vector<int>v2=v;
int r2=r;
while(r2--)nextthingy(v2);
int p=n;
for(int i=0;i<2*n;i++)
if(v2[i]==YOU)
p=i/2;
if(bst1>=p)bst2=i,bst1=p;
if(i<n-1)
swap(v[i*2],v[i*2+2]);
}
cout<<bst2+1<<'\n';
}
Compilation message
archery.cpp: In function 'void nextthingy(std::vector<int>&)':
archery.cpp:4:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
4 | for(int i=0;i<v.size();i+=2)
| ~^~~~~~~~~
archery.cpp:8:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
8 | for(int i=2;i<v.size();i+=2)
| ~^~~~~~~~~
archery.cpp: In function 'int main()':
archery.cpp:32:19: warning: 'bst2' may be used uninitialized in this function [-Wmaybe-uninitialized]
32 | cout<<bst2+1<<'\n';
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
25 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
36 ms |
436 KB |
Output is correct |
3 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
30 ms |
348 KB |
Output is correct |
7 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
8 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
11 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
12 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
13 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
14 |
Incorrect |
0 ms |
644 KB |
Output isn't correct |
15 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
16 |
Correct |
31 ms |
348 KB |
Output is correct |
17 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
18 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
24 |
Correct |
31 ms |
348 KB |
Output is correct |
25 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
26 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
27 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
28 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
29 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
30 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
31 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
32 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
33 |
Correct |
31 ms |
440 KB |
Output is correct |
34 |
Correct |
27 ms |
348 KB |
Output is correct |
35 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
36 |
Incorrect |
1 ms |
600 KB |
Output isn't correct |
37 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
38 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
39 |
Correct |
26 ms |
348 KB |
Output is correct |
40 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
41 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
42 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
43 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
44 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
45 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
46 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
47 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |