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 cum[101];
char S[101];
int concat(int l, int r, int op, int mode) {
return mode + (op << 1) + (r << 8) + (l << 15);
}
int Memory(int N, int M) {
if (N & 1) return -2;
if (M == 0) for (int i = 1; i <= N; ++i) cum[i] = 0;
S[1 + M] = Get(1 + M);
if (++M == N) {
for (int i = 1; i <= N; ++i) {
if (S[i] == '[' || S[i] == '<') ++cum[i];
else --cum[i];
cum[i] += cum[i - 1];
if (cum[i] < 0) return -2;
}
for (int i = 1; i <= N; ++i) {
if (S[i] == '[' || S[i] == '<') {
bool c = 0;
for (int j = i + 1; j <= N && !c; ++j) {
if (cum[i] == cum[j]) {
if (S[i] == '[' && S[j] == ']') c = 1;
else if (S[i] == '<' && S[j] == '>') c = 1;
else return -2;
}
}
}
}
if (cum[N] == 0) return -1;
else return -2;
}
return M;
}
# | 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... |