Submission #677480

#TimeUsernameProblemLanguageResultExecution timeMemory
67748079brue기억 압축 (JOI15_memory)C++17
0 / 100
0 ms212 KiB
#include "Memory_lib.h" #include <bits/stdc++.h> void translate(int st, int &i, int &j, int &depth, int &num){ num = st % 3; st /= 3; depth = st % 102; st /= 102; j = st % 102; st /= 102; i = st; } int translate(int i, int j, int depth, int num){ return ((i*102+j)*102+depth)*3+num; } int INF = (1<<22) - 100000; int Memory(int n, int _st){ int i, j, depth, num; translate(_st, i, j, depth, num); if(_st >= INF){ /// 우선 개수를 맞춰 본다. int tmp = _st - INF; int i = tmp / 300, j = tmp % 300; if(i == n+1) return (j == 150) ? translate(1, 1, 50, 0) : -2; char chr = Get(i); if(chr == '<' || chr == '[') return (INF + (i+1)*300 + (j+1)); else return (INF + (i+1)*300 + (j-1)); } if(i==n+1) return -1; if(j==n+1) return -2; if(i == 0) return (INF + 300 + 150); if(i > n+1 || j > n || j == 0) return -2; if(num){ /// i랑 j를 매칭 중 int chr = (Get(i) == '<') ? 1 : 2; if(chr != num) return -2; return translate(i+1, i+1, 50, 0); } else{ /// 아직 매칭 중이 아님 if(i==j){ char tmp = Get(i); if(tmp == ']' || tmp == '>') return translate(i+1, i+1, 50, 0); /// 이건 여는 괄호가 아님 return translate(i, i+1, 51, 0); } /// 맞는지 확인 char tmp = Get(j); if(tmp == '[' || tmp == '<') depth++; else depth--; if(depth == 50) return translate(i, j, depth, tmp == '>' ? 1 : 2); return translate(i, j+1, depth, 0); } }
#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...