Submission #728950

#TimeUsernameProblemLanguageResultExecution timeMemory
728950tjd229기억 압축 (JOI15_memory)C++14
0 / 100
2204 ms284216 KiB
#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 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...