# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
270704 |
2020-08-18T00:53:59 Z |
imeimi2000 |
None (JOI15_memory) |
C++17 |
|
3053 ms |
283772 KB |
#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 |
1 |
Correct |
2838 ms |
283608 KB |
Output is correct |
2 |
Correct |
2864 ms |
283668 KB |
Output is correct |
3 |
Correct |
2866 ms |
283684 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2838 ms |
283608 KB |
Output is correct |
2 |
Correct |
2864 ms |
283668 KB |
Output is correct |
3 |
Correct |
2866 ms |
283684 KB |
Output is correct |
4 |
Correct |
2863 ms |
283772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2838 ms |
283608 KB |
Output is correct |
2 |
Correct |
2864 ms |
283668 KB |
Output is correct |
3 |
Correct |
2866 ms |
283684 KB |
Output is correct |
4 |
Correct |
2863 ms |
283772 KB |
Output is correct |
5 |
Correct |
2875 ms |
283608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2838 ms |
283608 KB |
Output is correct |
2 |
Correct |
2864 ms |
283668 KB |
Output is correct |
3 |
Correct |
2866 ms |
283684 KB |
Output is correct |
4 |
Correct |
2863 ms |
283772 KB |
Output is correct |
5 |
Correct |
2875 ms |
283608 KB |
Output is correct |
6 |
Correct |
2951 ms |
283576 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2918 ms |
283636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2838 ms |
283608 KB |
Output is correct |
2 |
Correct |
2864 ms |
283668 KB |
Output is correct |
3 |
Correct |
2866 ms |
283684 KB |
Output is correct |
4 |
Correct |
2863 ms |
283772 KB |
Output is correct |
5 |
Correct |
2875 ms |
283608 KB |
Output is correct |
6 |
Correct |
2951 ms |
283576 KB |
Output is correct |
7 |
Correct |
2918 ms |
283636 KB |
Output is correct |
8 |
Correct |
2997 ms |
283548 KB |
Output is correct |
9 |
Correct |
3053 ms |
283508 KB |
Output is correct |