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 <cmath>
#include <vector>
#include <iostream>
using namespace std;
std::vector<std::vector<int>> devise_strategy(int N) {
vector<vector<int>> ans;
vector<int> temp(N+1,0);
int MX = 0;
int ten = 1;
if(N>999)ten=4;
if(N>99)ten=3;
if(N>9)ten=2;
for(int i=0;i<ten;i++){
temp = vector<int> (N+1,0);
// if(i==0){
// ans.push_back(temp);
// continue;
// }
for(int j=1;j<N+1;j++){
int a = (int)(j/pow(10,ten-1-i))%10;
temp[j] = (i+1)*10 + a;
MX = max(MX,temp[j]);
}
ans.push_back(temp);
}
for(int i=ten;i<10;i++){
temp = vector<int> (N+1,0);
ans.push_back(temp);
}
for(int i=10;i<MX+1;i++){
temp = vector<int> (N+1,0);
temp[0] = 1;
// cout << i << " -> ";
for(int j=1;j<N+1;j++){
int pos = i/10;
int a = i%10;
int b = (int)(j/pow(10,ten-pos))%10;
// cout << "{" << a << "," << b << "," << pos << "} ";
if(a>b)temp[j] = -2;
else if(a<b)temp[j] = -1;
else {
if((i/10) == ten)temp[j] = 0;
else temp[j] = (i/10);
}
}
// cout << endl;
ans.push_back(temp);
}
// int counter = 0;
// for(auto a: ans){
// cout << counter << " -> ";
// for(auto b: a){
// cout << b << " ";
// }cout << endl;
// counter ++;
// }
return ans;
}
// std::vector<std::vector<int>> devise_strategy(int N) {
// vector<vector<int>> ans;
// vector<int> temp(N+1,0);
// for(int j=1;j<N+1;j++){
// temp[j] = j;
// }
// ans.push_back(temp);
// for(int i=1;i<N+1;i++){
// temp = vector<int> (N+1,0);
// temp[0] = 1;
// for(int j=1;j<N+1;j++){
// if(i>j)temp[j]=-2;
// else if(i<j)temp[j]=-1;
// else temp[j]=0;
// }
// ans.push_back(temp);
// }
// int counter = 0;
// for(auto a: ans){
// cout << counter << " -> ";
// for(auto b: a){
// cout << b << " ";
// }cout << endl;
// counter ++;
// }
// return ans;
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |