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"
int Memory(int N, int M) {
int a, s, e, v;
a = M >> 21;
s = (M >> 14) & ((1 << 7) - 1);
e = (M >> 7) & ((1 << 7) - 1);
v = M & ((1 << 7) - 1);
if (s == N) return -1;
if (e >= N) return -2;
char c = Get(e + 1);
if (s == 0) {
if (c == '>' || c == ']') v--;
else v++;
if (v < 0 || (e + 1 == N && v)) return -2;
if (e + 1 == N) return 1 << 14;
return (e + 1) << 7 | v;
}
if (s == e + 1) {
if (c == '>' || c == ']') return ((s + 1) << 14) | (s << 7);
a = c != '<';
return (a << 21) | (s << 14) | (s << 7) | 1;
}
if (c == '>' || c == ']') v--;
else v++;
if (v == 0) {
if (a ^ (c != '>')) return -2;
return ((s + 1) << 14) | (s << 7);
}
return (a << 21) | (s << 14) | ((e + 1) << 7) | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |