Submission #593452

#TimeUsernameProblemLanguageResultExecution timeMemory
593452dantoh000기억 압축 (JOI15_memory)C++14
100 / 100
2270 ms284084 KiB
#include "Memory_lib.h" #include <bits/stdc++.h> int Memory(int N, int M) { int cidx = M&127; int idx = (M>>7)&127; int ct = (M>>14)&127; int type = M>>21; ///printf("cidx = %d, idx = %d, ct = %d, type = %d\n",cidx,idx,ct,type); if (idx > N) return -2; if (cidx == 0){ if (idx == 0){ idx++; } else{ char ch = Get(idx); if (ch == '<' || ch == '[') ct++; else ct--; if (ct < 0) return -2; if (idx == N){ if (ct != 0) return -2; else{ cidx++; idx=0; ct=0; type=0; } } else{ idx++; } } } else if (cidx <= N){ if (idx == 0){ char ch = Get(cidx); if (ch == '>' || ch == ']'){ cidx = cidx+1; } else{ idx = cidx+1; ct = 1; type = (ch=='<')?1:0; } } else{ char ch = Get(idx); if (ch == '>' || ch == ']') { ct--; idx++; if (ct < 0) return -2; if (ct == 0){ if ((ch=='>')==type){ cidx++; idx=0; ct=0; type=0; } else return -2; } } else { ct++; idx++; } } } else return -1; ///printf("new %d %d %d %d\n",cidx,idx,ct,type); M = (type<<21)|(ct<<14)|(idx<<7)|cidx; ///printf("%d\n",M); return M; }
#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...