QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#809875#1214. Limited Memoryzhouhuanyi100 ✓196ms86060kbC++14906b2024-12-11 17:59:172024-12-11 17:59:18

Judging History

你现在查看的是最新测评结果

  • [2024-12-11 17:59:18]
  • 评测
  • 测评结果:100
  • 用时:196ms
  • 内存:86060kb
  • [2024-12-11 17:59:17]
  • 提交

answer

#include "Memory_lib.h"
#include<iostream>
#include<cstdio>
using namespace std;
int calc(int a,int b,int c,int d)
{
	return min(a+b*101+c*10201+d*1030301,4194303);
}
int Memory(int N,int M)
{
	int a,b,c,d;
	char cs;
	a=M%101,M/=101,b=M%101,M/=101,c=M%101,M/=101,d=M;
	if (b>=N) return -2;
	if (a==N) return -1;
	if (a==0)
	{
		cs=Get(b+1);
		if (cs=='<'||cs=='[') c++;
		else c--;
		if (c<0) return -2;
		if (b+1==N&&c!=0) return -2;
		b++;
		if (b==N) return calc(1,0,0,0);
		else return calc(a,b,c,0);
	}
	else
	{
		if (b==a-1)
		{
			cs=Get(b+1);
			if (cs=='>'||cs==']') return calc(a+1,a,0,0);
			return calc(a,b+1,0,cs=='[');
		}
		else
		{
			cs=Get(b+1);
			if (cs=='<'||cs=='[') c++;
			else c--;
			if (c<0)
			{
				if ((cs==']')!=d) return -2;
				return calc(a+1,a,0,0);
			}
			b++;
			if (b==N) return -2;
			return calc(a,b,c,d);
		}
	}
}

Details

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 88ms
memory: 85700kb

Test #2:

score: 10
Accepted
time: 88ms
memory: 85744kb

Test #3:

score: 10
Accepted
time: 94ms
memory: 85912kb

Subtask #2:

score: 10
Accepted

Test #4:

score: 10
Accepted
time: 86ms
memory: 85800kb

Subtask #3:

score: 5
Accepted

Test #5:

score: 5
Accepted
time: 103ms
memory: 85876kb

Subtask #4:

score: 5
Accepted

Test #6:

score: 5
Accepted
time: 111ms
memory: 85792kb

Subtask #5:

score: 10
Accepted

Test #7:

score: 10
Accepted
time: 179ms
memory: 85780kb

Subtask #6:

score: 60
Accepted

Test #8:

score: 60
Accepted
time: 148ms
memory: 85868kb

Test #9:

score: 60
Accepted
time: 196ms
memory: 86060kb

Extra Test:

score: 0
Extra Test Passed