이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int f(int pos, int lvl, int sz, int v)
{
return pos|(lvl<<7)|(sz<<13)|(v<<20);
}
int Memory(int N, int M)
{
int i, j;
if(N%2) return -2;
if(M==0) return f(1, 1, 0, 0);
int pos=M&((1<<7)-1), lvl=(M>>7)&((1<<6)-1), sz=(M>>13)&((1<<6)-1), v=(M>>20)&1;
if(lvl>N/2) return -1;
if(pos>N+1) return -2;
if(pos==0) return -2;
if(pos==N+1)
{
if(sz!=0) return -2;
return f(1, lvl+1, 0, 0);
}
//printf("%d %d %d %d %d\n", M, pos, lvl, sz, v);
char c=Get(pos);
if(c=='<')
{
sz++;
if(sz>N/2) return -2;
if(sz==lvl) v=0;
}
else if(c=='[')
{
sz++;
if(sz>N/2) return -2;
if(sz==lvl) v=1;
}
else if(c=='>')
{
if(sz==lvl)
{
if(v==1) return -2;
}
sz--;
if(sz<0) return -2;
}
else if(c==']')
{
if(sz==lvl)
{
if(v==0) return -2;
}
sz--;
if(sz<0) return -2;
}
pos++;
return f(pos, lvl, sz, v);
}
컴파일 시 표준 에러 (stderr) 메시지
memory.cpp: In function 'int Memory(int, int)':
memory.cpp:16:6: warning: unused variable 'i' [-Wunused-variable]
int i, j;
^
memory.cpp:16:9: warning: unused variable 'j' [-Wunused-variable]
int i, j;
^
# | 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... |