This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 sz, int mch, int st)
{
	return (st<<8)|(mch<<4)|(sz);
}
int Memory(int N, int M)
{
	if(N%2) return -2;
	int sz=M&15; M>>=4;
	int mch=M&15; M>>=4;
	int st=M;
	if(sz>N/2) return -2;
	if(mch>N/2) return -2;
	if(st>=(1<<(N/2))) return -2;
	if(mch*2+sz>=N) return -2;
	char c=Get(mch*2+sz+1);
	if(c=='<')
	{
		st<<=1;
		sz++;
		if(sz>N/2) return -2;
	}
	else if(c=='[')
	{
		st<<=1;
		st|=1;
		sz++;
		if(sz>N/2) return -2;
	}
	else if(c=='>')
	{
		if(sz==0) return -2;
		if((st&1)!=0) return -2;
		sz--; st>>=1; mch++;
	}
	else if(c==']')
	{
		if(sz==0) return -2;
		if((st&1)!=1) return -2;
		sz--; st>>=1; mch++;
	}
	if(mch*2+sz==N)
	{
		if(sz==0) return -1;
		return -2;
	}
	return encode(sz, mch, st);
}
| # | 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... |