Submission #626504

#TimeUsernameProblemLanguageResultExecution timeMemory
626504KaitokidPrisoner Challenge (IOI22_prison)C++17
65 / 100
13 ms1244 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; vector<vector<int> > devise_strategy(int N) { int u=0; int d=N; while(d>1){u++;d/=2;} vector<vector<int> > s(2*u+1,vector<int>(N+1,0)); for(int i=1;i<=u;i++) { if(i%2) s[i][0]=1;else s[i][0]=0; for(int j=1;j<=N;j++) if(j&(1<<i)){if(i%2)s[i][j]=-1;else s[i][j]=-2;} else {if(j&(1<<(i-1)))s[i][j]=u+i-1;else s[i][j]=i-1;} } for(int i=1;i<=u;i++) { if(i%2) s[i+u][0]=1;else s[i+u][0]=0; for(int j=1;j<=N;j++) if(!(j&(1<<i))){if(i%2)s[i+u][j]=-2;else s[i+u][j]=-1;} else {if(j&(1<<(i-1)))s[i+u][j]=u+i-1;else s[i+u][j]=i-1;} } for(int j=1;j<=N;j++) if(s[1][j]>=0) if(j&1)s[1][j]=-1;else s[1][j]=-2; for(int j=1;j<=N;j++) if(s[u+1][j]>=0) if(j&1)s[u+1][j]=-1;else s[u+1][j]=-2; if((u+1)%2)s[0][0]=1; else s[0][0]=0; for(int j=1;j<=N;j++) if(j&(1<<u))s[0][j]=2*u; else s[0][j]=u; return s; }/* int main() { vector<vector<int> > v=devise_strategy(4); cout<<v.size()<<endl; for(int i=0;i<v.size();i++) { for(int j=0;j<v[i].size();j++)cout<<v[i][j]<<" "; cout<<endl; } return 0; } */

Compilation message (stderr)

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:25:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   25 |     if(s[1][j]>=0)
      |       ^
prison.cpp:24:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   24 |    for(int j=1;j<=N;j++)
      |    ^~~
prison.cpp:27:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   27 |     for(int j=1;j<=N;j++)
      |     ^~~
prison.cpp:28:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   28 |     if(s[u+1][j]>=0)
      |     ^~
prison.cpp:30:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   30 |      if((u+1)%2)s[0][0]=1; else s[0][0]=0;
      |      ^~
prison.cpp:28:7: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
   28 |     if(s[u+1][j]>=0)
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...