Submission #825710

#TimeUsernameProblemLanguageResultExecution timeMemory
825710alvingogoPrisoner Challenge (IOI22_prison)C++17
0 / 100
121 ms1004 KiB
#include "prison.h" #include <bits/stdc++.h> #define fs first #define sc second #define p_q priority_queue using namespace std; int n; vector<vector<int> > ans; vector<vector<int>> devise_strategy(int N) { const int g[]={2,8,26,80,242,728,1458,2918,5838}; int w=0; for(;;w++){ if(g[w]>=N){ n=g[w]; break; } } w--; vector<int> pz(n+1); pz[0]=0; for(int i=1;i<=n;i++){ int s=(i-1)%g[w+1]; if(s==0){ pz[i]=-1; } else if(s==n-1){ pz[i]=-2; } else{ pz[i]=(s-1)/g[w]+1; } } ans.push_back(pz); int q=1+(g[w+1]-2)/g[w],l=2; int fl=1; vector<int> vis(n+1); vis[1]=-1; vis[n]=1; for(w--;w>=-1;w--){ int p=(g[w+2]-2)/g[w+1]; vector<vector<int> > pp(p); for(int i=0;i<p;i++){ pp[i].resize(n+1); pp[i][0]=fl; } //cout << l << " " << g[w+2] << "\n"; for(int j=1;j<=n;j++){ if(!vis[j]){ for(int i=0;i<p;i++){ int j2=(j-(l-1))%g[w+2]; //assert(j2>=0); int s1=(j2-1)/g[w+1]; if(s1<i){ pp[i][j]=-1-fl; } else if(s1>i){ pp[i][j]=fl-2; } else{ int s2=(j2-1+g[w+1])%g[w+1]; if(s2==0){ pp[i][j]=-1-fl; vis[j]=-1; } else if(s2==g[w+1]-1){ pp[i][j]=fl-2; vis[j]=1; } else{ pp[i][j]=q+(s2-1)/g[w]; } } } } else{ for(int i=0;i<p;i++){ if(vis[j]==1){ pp[i][j]=fl-2; } else{ pp[i][j]=-1-fl; } } } } for(auto h:pp){ ans.push_back(h); } if(w<0){ break; } int s=(g[w+1]-2)/g[w]; q+=s; fl^=1; l++; } //cout << vis[35] << " " << vis[36] << '\n'; freopen("err.txt","w",stderr); for(auto &h:ans){ while(h.size()>(N+1)){ h.pop_back(); } for(int i=0;i<=n;i++){ cerr << h[i] << " "; } cerr << '\n'; } return ans; }

Compilation message (stderr)

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:101:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  101 |         while(h.size()>(N+1)){
      |               ~~~~~~~~^~~~~~
prison.cpp:99:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   99 |     freopen("err.txt","w",stderr);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...