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 "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;
int Memory(int N, int M) {
if (N>30){
int loc = M%(N+1);
int rem = M/(N+1);
if (loc==N) return rem==0?-1:-2;
int res = Get(loc+1);
if (res=='>'){
if (rem==0) return -2;
rem--;
}
else{
rem++;
}
return rem*(N+1)+loc+1;
}
int loc = M%(N+1);
int rem = M/(N+1);
int rems = rem&15;
int remm = rem>>4;
if (loc==N){
return rems==0?-1:-2;
}
int res = Get(loc+1);
if (res==']' || res=='>'){
if (rems==0) return -2;
if ((remm&1)==(res==']')){
rems--;
remm>>=1;
}
else{
return -2;
}
}
else{
if (rems==15){
return -2;
}
rems++;
remm<<=1;
remm += (res=='[');
}
return ((remm<<4)+rems)*(N+1)+(loc+1);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |