Submission #315301

#TimeUsernameProblemLanguageResultExecution timeMemory
315301amunduzbaevJousting tournament (IOI12_tournament)C++14
0 / 100
15 ms1408 KiB
//#include "grader.cpp" #include <bits/stdc++.h> using namespace std; int n, c, last, k[505], s[505], e[505], tmp2[505]; int solve(int pos){ vector<int>tmp(n); int j=0; for(int i=0;i<n;i++) tmp[i]=tmp2[i]; for(int i=0;i<c;i++){ int l=s[i], r=e[i],m=0; for(;l<=r;l++) m=max(m,tmp[l]); auto ll=tmp.begin(),rr=tmp.begin(); ll=ll+s[i]; rr=rr+r; tmp.erase(ll,rr); tmp[s[i]]=m; if(m==last) j++; } return j; } int GetBestPosition(int N, int C, int R, int *K, int *S, int *E) { n=N, c=C, last=R; for(int i=0;i<n-1;i++) k[i]=K[i]; for(int i=0;i<c;i++) s[i]=S[i],e[i]=E[i]; tmp2[0]=last; for(int i=1;i<n;i++) tmp2[i]=k[i-1]; int ans,mx=0; for(int pos=0;pos<n;pos++){ int sl=solve(pos); if(sl>mx){ mx=sl; ans=pos; } swap(tmp2[pos],tmp2[pos+1]); } return ans; } /* 5 3 3 1 0 2 4 1 3 0 1 0 1 */

Compilation message (stderr)

tournament.cpp: In function 'int GetBestPosition(int, int, int, int*, int*, int*)':
tournament.cpp:39:12: warning: 'ans' may be used uninitialized in this function [-Wmaybe-uninitialized]
   39 |     return ans;
      |            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...