Submission #282847

# Submission time Handle Problem Language Result Execution time Memory
282847 2020-08-25T04:35:45 Z arnold518 None (JOI15_memory) C++14
0 / 100
3031 ms 283876 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(!(1<=top && top<=N+1)) 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(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:79:1: warning: control reaches end of non-void function [-Wreturn-type]
   79 | }
      | ^
# Verdict Execution time Memory Grader output
1 Correct 2878 ms 283876 KB Output is correct
2 Incorrect 3028 ms 283596 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2878 ms 283876 KB Output is correct
2 Incorrect 3028 ms 283596 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2878 ms 283876 KB Output is correct
2 Incorrect 3028 ms 283596 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2878 ms 283876 KB Output is correct
2 Incorrect 3028 ms 283596 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3031 ms 283784 KB Wrong Answer [6]
# Verdict Execution time Memory Grader output
1 Correct 2878 ms 283876 KB Output is correct
2 Incorrect 3028 ms 283596 KB Wrong Answer [6]
3 Halted 0 ms 0 KB -