# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
56906 |
2018-07-13T06:46:33 Z |
정원준(#1637) |
None (JOI15_memory) |
C++11 |
|
2 ms |
376 KB |
#include<Memory_lib.h>
#include <bits/stdc++.h>
using namespace std;
char Get(int I);
int trans(char a){
if(a=='[') return 1;
if(a==']') return 4;
if(a=='<') return 2;
if(a=='>') return 3;
}
int pack(int s,int h,int n,int f,int e){
int ret=0;
//h--;
//n--;
f--;
ret+=s<<19;
ret+=h*10100+n*100+f;
ret<<=1;
ret+=e;
return ret;
}
int Memory(int N,int M){
int ended,state,height,now,far,locvalues;
if(M==0)
{
ended=0;
state=0;
height=0;
now=1;
far=0;
}
else
{
ended=M%2;
M/=2;
state=(M>>19);
locvalues=(M-(state<<19));
height=locvalues/10100;
now=(locvalues/100)%101;
far=locvalues%100+1;
}
//printf("%d %d %d %d %d\n",state,height,now,far,ended);
if(ended)
{
if(now==0) return height==1?-1:-2;
int temp=trans(Get(now));
if(temp<=2) height--;
else height++;
if(height<1) return -2;
now--;
return pack(state,height,now,far,ended);
}
if(state)
{
if(now<1) return -2;
int temp=trans(Get(now));
if(temp<=2) height--;
else height++;
if(height==0)
{
if(temp+state!=5) return -2;
state=0;
height=0;
now++;
return pack(state,height,now,far,ended);
}
else
{
now--;
//printf("%lld\n",now);
return pack(state,height,now,far,ended);
}
}
else
{
if(now>far)
{
far=now;
if(now>N)
{
ended=1;
height=1;
now--;
return pack(state,height,now,far,ended);
}
else
{
int temp=trans(Get(now));
if(temp<=2)
{
now++;
return pack(state,height,now,far,ended);
}
else
{
state=temp;
height=1;
now--;
return pack(state,height,now,far,ended);
}
}
}
else
{
now++;
return pack(state,height,now,far,ended);
}
}
}
/*
int n,tc;
char str[111];
char Get(int I){
return str[I-1];
}
int main()
{
scanf("%d %d %s",&n,&tc,str);
int mem=0,cnt;
do
{
mem=Memory(n,mem);
cnt++;
if(mem<0) break;
}while(1);
printf("%d %d",mem,cnt);
}*/
Compilation message
memory.cpp: In function 'int trans(char)':
memory.cpp:13:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Wrong Answer [1] |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Wrong Answer [3] |
2 |
Halted |
0 ms |
0 KB |
- |