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 <vector>
int cyfra(int pozycja, int liczba){
liczba++;
if(pozycja>8) return 0;
//return 1;
int c = 0;
int p = 2187;
for(int i=1; i<=pozycja; i++){
c=0;
while(liczba>p){
liczba-=p;
c++;
}
p/=3;
}
return c;
}
int transform(int j){
if(j<=8) return j;
if(j<=18) return j-2;
return j-4;
}
std::vector<std::vector<int>> devise_strategy(int N) {
int X = 30;
int Y = 24;
//return {std::vector<int>(N + 1, 0)};
std::vector<std::vector<int>> V(Y+1);
int c = 0;
for(auto &w : V){w.resize(N+1); w[0] = c; c+=1; c%=2;}
for(int j=1; j<=N; j++){
V[0][j] = transform(cyfra(1,j) * 10 + 1);
}
for(int i=1; i<=X; i++){
if(i%10 == 9 || i%10 == 0) continue;
for(int j=1; j<=N; j++){
if(i%2){ //sprawdzam worek B, mam A
int aktB = cyfra(i%10,j); // cyfra z B
int aktA = i/10; // cyfra z A
if(aktB == aktA){
V[transform(i)][j] = transform(cyfra((i%10)+1,j) * 10 + ((i%10)+1));
}else if(aktB<aktA) V[transform(i)][j] = -2;
else if(aktA<aktB) V[transform(i)][j] = -1;
}else{ //sprawdzam worek A, mam B
int aktA = cyfra(i%10,j); // cyfra z A
int aktB = i/10; // cyfra z B
if(aktB == aktA){
V[transform(i)][j] = transform(cyfra((i%10)+1,j) * 10 + ((i%10)+1));
}else if(aktB<aktA) V[transform(i)][j] = -2;
else if(aktA<aktB) V[transform(i)][j] = -1;
}
}
}
return V;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |