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 <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;
int Memory(int N, int M) {
//cout<<N<<" "<<M<<endl;
int idx = (M>>14);
int a = (M>>7)%(1<<7);
int b = M%(1<<7);
//cout<<idx<<" "<<a<<" "<<b<<endl;
if(idx==0){
idx++;
int K = (idx<<14) + (a<<7) + b;
//cout<<idx<<" "<<a<<" "<<b<<endl;
return K;
}
if(idx==N+1){
if(a==0 && b==0){
return -1;
}return -2;
}
if(idx>N+1){
return -2;
}
//cout<<idx<<endl;
char c = Get(idx);
//cout<<c<<endl;
if(c=='<'){
a++;
}else if(c=='>'){
a--;
if(a<0) return -2;
}else if(c=='['){
b++;
}else if(c==']'){
b--;
if(b<0) return -2;
}else{
return -2;
}
idx++;
int K = (idx<<14) + (a<<7) + b;
//cout<<idx<<" "<<a<<" "<<b<<endl;
return K;
}
# | 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... |