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 <bits/stdc++.h>
using namespace std;
#include "prison.h"
#include <vector>
std::vector<std::vector<int>> devise_strategy(int n) {
function<void(int,int,int,int)> solve;
vector<int> yeni(n+1,0);
vector<vector<int>> ansarr;
ansarr.push_back(yeni);
int crr = 1;
solve = [&](int l, int r, int turn, int x){
ansarr[x][0]=turn;
for (int i = 1; i < l; i++){
ansarr[x][i]=-turn-1;
}
for (int i = r+1; i < ansarr[x].size(); i++){
ansarr[x][i]=turn-2;
}
if (l>r) return;
int mid = l+(r-l)/2;
ansarr.push_back(yeni);
ansarr.push_back(yeni);
for (int i = l; i <= mid; i++){
ansarr[x][i]=crr;
}
solve(l,mid,1-turn,crr);
crr++;
for (int i = mid+1; i <= r; i++){
ansarr[x][i]=crr;
}
solve(mid+1,r,1-turn,crr);
};
solve(1,n,0,0);
/*
for (int i = 0; i < ansarr.size(); i++){
for (int j = 0; j < ansarr[i].size(); j++){
cout<<ansarr[i][j]<<" ";
}
cout<<endl;
}
*/
return ansarr;
}
Compilation message (stderr)
prison.cpp: In lambda function:
prison.cpp:17:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | for (int i = r+1; i < ansarr[x].size(); i++){
| ~~^~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |