# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
282850 |
2020-08-25T04:39:29 Z |
arnold518 |
None (JOI15_memory) |
C++14 |
|
3125 ms |
283964 KB |
#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 encode(int type, int top, int pos, int off)
{
int ret=0;
ret|=type;
ret<<=7; ret|=top;
ret<<=7; ret|=pos;
ret<<=6; ret|=off;
return ret;
}
int Memory(int N, int M)
{
if(N%2) return -2;
if(M==0) return encode(0, 0, 1, 0);
int type, top, pos, off;
off=M&((1<<6)-1); M>>=6;
pos=M&((1<<7)-1); M>>=7;
top=M&((1<<7)-1); M>>=7;
//printf("%d %d %d %d\n", type, top, pos, off);
type=M;
if(!(top<pos)) return -2;
if(!(1<=pos && pos<=N+1)) return -2;
if(!(0<=top && top<=N)) return -2;
if(!(off<=N/2)) return -2;
if(type==0)
{
if(off!=0) return -2;
if(pos==N+1)
{
if(top==0) return -1;
return -2;
}
if(!(1<=pos && pos<=N)) return -2;
char c=Get(pos);
if(c=='>') return encode(1, top, pos, 0);
if(c==']') return encode(2, top, pos, 0);
if(c=='<') return encode(0, pos, pos+1, 0);
if(c=='[') return encode(0, pos, pos+1, 0);
}
else if(type==1)
{
if(top==0) return -2;
if(!(1<=top && top<=N)) return -2;
char c=Get(top);
if(c!='<') return -2;
return encode(3, top-1, pos+1, 0);
}
else if(type==2)
{
if(top==0) return -2;
if(!(1<=top && top<=N)) return -2;
char c=Get(top);
if(c!='[') return -2;
return encode(3, top-1, pos+1, 0);
}
else
{
char c;
if(top==0) c='<';
else if(top<=N) c=Get(top);
else return -2;
if(c==']' || c=='>') off++;
else off--;
if(top==0 && off>=0) return -2;
if(off<0) return encode(0, top, pos, 0);
return encode(3, top-1, pos, off);
}
}
Compilation message
memory.cpp: In function 'int Memory(int, int)':
memory.cpp:81:1: warning: control reaches end of non-void function [-Wreturn-type]
81 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2819 ms |
283884 KB |
Output is correct |
2 |
Correct |
2904 ms |
283680 KB |
Output is correct |
3 |
Correct |
2866 ms |
283784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2819 ms |
283884 KB |
Output is correct |
2 |
Correct |
2904 ms |
283680 KB |
Output is correct |
3 |
Correct |
2866 ms |
283784 KB |
Output is correct |
4 |
Correct |
2849 ms |
283892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2819 ms |
283884 KB |
Output is correct |
2 |
Correct |
2904 ms |
283680 KB |
Output is correct |
3 |
Correct |
2866 ms |
283784 KB |
Output is correct |
4 |
Correct |
2849 ms |
283892 KB |
Output is correct |
5 |
Correct |
2849 ms |
283896 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2819 ms |
283884 KB |
Output is correct |
2 |
Correct |
2904 ms |
283680 KB |
Output is correct |
3 |
Correct |
2866 ms |
283784 KB |
Output is correct |
4 |
Correct |
2849 ms |
283892 KB |
Output is correct |
5 |
Correct |
2849 ms |
283896 KB |
Output is correct |
6 |
Correct |
2881 ms |
283964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3125 ms |
283748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2819 ms |
283884 KB |
Output is correct |
2 |
Correct |
2904 ms |
283680 KB |
Output is correct |
3 |
Correct |
2866 ms |
283784 KB |
Output is correct |
4 |
Correct |
2849 ms |
283892 KB |
Output is correct |
5 |
Correct |
2849 ms |
283896 KB |
Output is correct |
6 |
Correct |
2881 ms |
283964 KB |
Output is correct |
7 |
Correct |
3125 ms |
283748 KB |
Output is correct |
8 |
Correct |
2823 ms |
283840 KB |
Output is correct |
9 |
Correct |
3014 ms |
283728 KB |
Output is correct |