# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
56916 |
2018-07-13T07:17:11 Z |
정원준(#1637) |
None (JOI15_memory) |
C++11 |
|
3800 ms |
276880 KB |
#include <Memory_lib.h>
#include <bits/stdc++.h>
using namespace std;
char Get(int I);
int trans(char a){
if(a=='[') return 0;
if(a==']') return 3;
if(a=='<') return 1;
if(a=='>') return 2;
}
int pack(int s,int h,int n,int f,int e){
//printf("%d %d %d %d %d\n",s,h,n,f,e);
int ret=0;
//h--;
//n--;
f--;
ret+=s<<19;
ret+=h*10100+n*100+f;
ret<<=1;
ret+=e;
if(ret<0||ret>=(1<<22)) return -2;
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)
{
//while(1);
return -1;
}
if(now<1||now>N) return -2;
int temp=trans(Get(now));
if(temp<=1) height--;
else height++;
if(height<1) return -2;
now--;
return pack(state,height,now,far,ended);
}
if(height)
{
if(now<1) return -2;
if(now<1||now>N) return -2;
int temp=trans(Get(now));
if(temp<=1) height--;
else height++;
if(height==0)
{
if(temp+state!=3) 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
{
if(now<1||now>N) return -2;
int temp=trans(Get(now));
if(temp<=1)
{
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];
void E(int x){
printf("Wrong answer %d",x);
}
char Get(int I){
if(I<1||I>n)
E(3);
return str[I-1];
}
int main()
{
scanf("%d %d",&n,&tc);
int i;
for(i=1;i<=tc;i++)
{
scanf("%s",str);
int mem=0,cnt=0;
do
{
mem=Memory(n,mem);
cnt++;
if(mem<0) break;
}while(1);
printf("%d %d\n",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 |
Correct |
3566 ms |
276800 KB |
Output is correct |
2 |
Correct |
3564 ms |
276800 KB |
Output is correct |
3 |
Correct |
2997 ms |
276820 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3566 ms |
276800 KB |
Output is correct |
2 |
Correct |
3564 ms |
276800 KB |
Output is correct |
3 |
Correct |
2997 ms |
276820 KB |
Output is correct |
4 |
Correct |
3166 ms |
276880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3566 ms |
276800 KB |
Output is correct |
2 |
Correct |
3564 ms |
276800 KB |
Output is correct |
3 |
Correct |
2997 ms |
276820 KB |
Output is correct |
4 |
Correct |
3166 ms |
276880 KB |
Output is correct |
5 |
Correct |
3715 ms |
276880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3566 ms |
276800 KB |
Output is correct |
2 |
Correct |
3564 ms |
276800 KB |
Output is correct |
3 |
Correct |
2997 ms |
276820 KB |
Output is correct |
4 |
Correct |
3166 ms |
276880 KB |
Output is correct |
5 |
Correct |
3715 ms |
276880 KB |
Output is correct |
6 |
Correct |
3800 ms |
276880 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3797 ms |
276880 KB |
Wrong Answer [6] |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3566 ms |
276800 KB |
Output is correct |
2 |
Correct |
3564 ms |
276800 KB |
Output is correct |
3 |
Correct |
2997 ms |
276820 KB |
Output is correct |
4 |
Correct |
3166 ms |
276880 KB |
Output is correct |
5 |
Correct |
3715 ms |
276880 KB |
Output is correct |
6 |
Correct |
3800 ms |
276880 KB |
Output is correct |
7 |
Incorrect |
3797 ms |
276880 KB |
Wrong Answer [6] |