# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
57144 | gs13105 | 기억 압축 (JOI15_memory) | C++17 | 4335 ms | 277028 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "Memory_lib.h"
const int spos_inf = (1 << 7) - 1;
inline int extract(int x, int off, int siz)
{
return x >> off & (1 << siz) - 1;
}
int Memory(int N, int M) {
if(N % 2 == 1)
return -2;
int cpos = extract(M, 0, 7);
int spos = extract(M, 7, 7);
int snum = extract(M, 14, 6);
int ctyp = extract(M, 20, 1);
int runs = extract(M, 21, 1);
spos = ~spos & (1 << 7) - 1;
if(cpos >= N || spos != spos_inf && (spos >= cpos || snum > N / 2))
return -2;
if(runs == 0)
{
if(spos == spos_inf)
{
char c = Get(cpos + 1);
if(c == '<' || c == '[')
cpos++;
else
{
if(cpos == 0)
return -2;
spos = cpos - 1;
snum = 0;
ctyp = (c == '>') ? 0 : 1;
}
}
else
{
char c = Get(spos + 1);
if(snum == 0 && (c == '<' || c == '['))
{
if(c == '<' && ctyp == 0 || c == '[' && ctyp == 1)
{
cpos++;
spos = spos_inf;
}
else
return -2;
}
else
{
if(spos == 0)
return -2;
spos--;
if(c == '<' || c == '[')
snum--;
else
snum++;
}
}
if(cpos == N)
{
cpos = 0;
spos = spos_inf;
runs = 1;
}
}
else
{
if(spos == spos_inf)
{
char c = Get(N - cpos);
if(c == '>' || c == ']')
cpos++;
else
{
if(cpos == 0)
return -2;
spos = cpos - 1;
snum = 0;
ctyp = (c == '<') ? 0 : 1;
}
}
else
{
char c = Get(N - spos);
if(snum == 0 && (c == '>' || c == ']'))
{
if(c == '>' && ctyp == 0 || c == ']' && ctyp == 1)
{
cpos++;
spos = spos_inf;
}
else
return -2;
}
else
{
if(spos == 0)
return -2;
spos--;
if(c == '>' || c == ']')
snum--;
else
snum++;
}
}
if(cpos == N)
return -1;
}
spos = ~spos & (1 << 7) - 1;
return cpos + (spos << 7) + (snum << 14) + (ctyp << 20) + (runs << 21);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |