Submission #829452

#TimeUsernameProblemLanguageResultExecution timeMemory
829452FatihSolakPrisoner Challenge (IOI22_prison)C++17
56 / 100
13 ms1108 KiB
#include "prison.h" #include <bits/stdc++.h> #include <vector> using namespace std; vector<vector<int>> devise_strategy(int N){ vector<vector<int>> ans; int st = 0; int used = 1; ans.push_back(vector<int>(N+1,0)); ans[0][0] = 0; vector<int> links; links.push_back(used++); links.push_back(used++); ans.push_back(vector<int>(N+1,0)); ans.push_back(vector<int>(N+1,0)); int num = 12; for(int i =1;i<=N;i++){ ans[0][i] = links[!!(i & (1<<num))]; } ans[links[0]][0] = 1; ans[links[1]][0] = 1; // cout << N << endl; // cout << ans.size() << endl; // cout << ans[0].size() << endl; // for(int i = 0;i<used;i++){ // for(int j = 0;j<N;j++){ // cout << ans[i][j] << ' '; // } // cout << endl; // } for(int i = num;i>=0;i--){ vector<int> nwlinks; if(i > 0){ nwlinks.push_back(used++); nwlinks.push_back(used++); ans.push_back(vector<int>(N+1,0)); ans.push_back(vector<int>(N+1,0)); ans[nwlinks[0]][0] = (ans[links[0]][0] == 0?1:0); ans[nwlinks[1]][0] = (ans[links[0]][0] == 0?1:0); } for(int j = 1;j<=N;j++){ if(j & (1<<i)){ ans[links[0]][j] = (ans[links[0]][0] == 0?-2:-1); if(i > 0) ans[links[1]][j] = (nwlinks[!!(j & (1<<(i-1)))]); } else{ ans[links[1]][j] = (ans[links[1]][0] == 0?-1:-2); if(i > 0) ans[links[0]][j] = (nwlinks[!!(j & (1<<(i-1)))]); } } links = nwlinks; } // cout << used << endl; // for(int i = 0;i<used;i++){ // for(int j = 0;j<N+1;j++){ // cout << ans[i][j] << ' '; // } // cout << endl; // } // for(auto u:ans){ // for(int j = 0;N+1;j++){ // cout << u[j] <<' ' ; // } // cout << endl; // } return ans; }

Compilation message (stderr)

prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:8:6: warning: unused variable 'st' [-Wunused-variable]
    8 |  int st = 0;
      |      ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...