Submission #1021638

#TimeUsernameProblemLanguageResultExecution timeMemory
1021638vjudge1Archery (IOI09_archery)C++17
31 / 100
36 ms644 KiB
#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 (stderr)

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';
      |                   ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...