Submission #270704

#TimeUsernameProblemLanguageResultExecution timeMemory
270704imeimi2000기억 압축 (JOI15_memory)C++17
100 / 100
3053 ms283772 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...