이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Memory_lib.h"
int Memory(int N, int M) {
int check = M & 127;
int pos = (M >> 7) & 127;
int sum = (M >> 14) & 127;
int type = (M >> 21);
if (N <= pos) return -1;
if (check == N) {
char c = Get(pos + 1);
if (c == '<' || c == '[') ++sum;
else --sum;
if (sum < 0) return -2;
if (++pos == N) {
if (sum != 0) return -2;
return -1;
}
int ret = (check | (pos << 7) | (sum << 14) | (type << 21));
if ((1 << 22) <= ret) return -1;
return ret;
}
switch (Get(pos + 1)) {
case '<':
if (check == pos) type = 0;
else if (check < pos) ++sum;
break;
case '>':
if (check == pos) {
pos = check++;
sum = 0;
break;
}
else if (check < pos) if (--sum < 0) {
if (type != 0) return -2;
pos = check++;
sum = 0;
break;
}
break;
case '[':
if (check == pos) type = 1;
else if (check < pos) ++sum;
break;
case ']':
if (check == pos) {
pos = check++;
sum = 0;
break;
}
else if (check < pos) if (--sum < 0) {
if (type != 1) return -2;
pos = check++;
sum = 0;
break;
}
break;
}
if (check == N) {
pos = 0;
sum = 0;
}
else if (++pos == N) return -2;
int ret = (check | (pos << 7) | (sum << 14) | (type << 21));
if ((1 << 22) <= ret) return -1;
return ret;
}
# | 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... |