Submission #677444

#TimeUsernameProblemLanguageResultExecution timeMemory
677444mjhmjh1104기억 압축 (JOI15_memory)C++17
0 / 100
1909 ms284112 KiB
#include "Memory_lib.h" int pack(int x, int y, int z, bool w) { return (x << 15) | (y << 8) | (z << 1) | w; } char get(int x) { return Get(x + 1); } int Memory(int n, int m) { if (n % 2) return -2; int x = (m >> 15) & 127; int y = (m >> 8) & 127; int z = (m >> 1) & 127; bool w = m & 1; if (z > n) { if (z < n + 4) { // step 2 if (z == n + 1) { char c = get(y - 1); if (c == ']') z = n + 2; else if (c == '>') z = n + 3; else return -2; return pack(x, y, z, w); } else if (z == n + 2) { char c = get(x); if (c != '[') return -2; } else { char c = get(x); if (c != '<') return -2; } x++; y = x; z = 0; w = false; return pack(x, y, z, w); } else { // step 3 if (z == n + 4) { char c = get(y); if (c == ']') z = n + 5; else if (c == '>') z = n + 6; else { x = y; w = false; z = 0; return pack(x, y, z, w); } return pack(x, y, z, w); } else if (z == n + 5) { char c = get(x); if (c != '[') { x = y; w = false; z = 0; return pack(x, y, z, w); } } else { char c = get(x); if (c != '<') { x = y; w = false; z = 0; return pack(x, y, z, w); } } x--; y++; z = n + 4; if (x < 0 || y >= n) { x = y; w = false; z = 0; return pack(x, y, z, w); } return pack(x, y, z, w); } } else { if (!w) { // step 1 if (x == y || z) { if (y >= n) { if (z) return -2; w = true; z = 0; return pack(x, y, z, w); } char c = get(y); if (c == '[' || c == '<') z++; else z--; if (z < 0) { w = true; z = 0; return pack(x, y, z, w); } y++; return pack(x, y, z, w); } else { z = n + 1; return pack(x, y, z, w); } } else { // step 4 if (x == 0 && y == n) return -1; if (!x) return -2; x--; char c = get(x); if (c == ']' || c == '>') z++; else z--; if (z < 0) { z = n + 4; return pack(x, y, z, w); } return pack(x, y, z, w); } } }
#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...