이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
else if(N>99)ten=3;
else 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);
}
// FILE *log_file = fopen("log1.txt","w");
// int counter = 0;
// for(auto a: ans){
// fprintf(log_file, "%d -> ", counter);
// for(auto b: a){
// fprintf(log_file, "%d ", b);
// }
// fprintf(log_file, "\n");
// counter ++;
// }
// fflush(log_file);
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... |