# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
829452 | FatihSolak | Prisoner Challenge (IOI22_prison) | C++17 | 13 ms | 1108 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |