Submission #199204

# Submission time Handle Problem Language Result Execution time Memory
199204 2020-01-30T03:56:15 Z arnold518 None (JOI15_memory) C++14
40 / 100
2853 ms 284152 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 Memory(int N, int M)
{
	int i, j;

	if(N>30)
	{
		int pos=M/1000, val=M%1000;
	 
		if(pos>N) return -2;
		if(pos==N)
		{
			if(val==0) return -1;
			return -2;
		}
	 
		assert(pos+1<=N);
		char t=Get(pos+1);
		if(t=='<') val++;
		else val--;
		pos++;
	 
		if(val<0) return -2;
	 
		return val+pos*1000;
	}

	//printf("%d\n", M);
	if(N%2) return -2;

	if(M==0) return 33;
	int pos=(M&31), mask=M>>5, sz;

	if(mask==0) return -2;
	if(pos==0) return -2;

	for(i=16; i>=0; i--) if(mask&(1<<i)) { sz=i; break; }

	if(sz>N/2) return -2;
	if(pos==N+1)
	{
		if(sz==0 && mask==1) return -1;
		return -2;
	}
	if(pos>N) return -2;

	char t=Get(pos);

	//printf("%d -> %d %d %d %c\n", M, pos, mask, sz, t);

	if(t=='<')
	{
		mask<<=1; sz++;
		if(sz>N/2) return -2;
	}
	else if(t=='[')
	{
		mask<<=1; sz++;
		mask|=1;
		if(sz>N/2) return -2;
	}
	else if(t=='>')
	{
		if(sz==0) return -2;
		if((mask&1)==1) return -2;
		sz--; mask>>=1;
	}
	else if(t==']')
	{
		if(sz==0) return -2;
		if((mask&1)==0) return -2;
		sz--; mask>>=1;
	}
	pos++;

	return (mask<<5)|pos;
}

Compilation message

memory.cpp: In function 'int Memory(int, int)':
memory.cpp:11:9: warning: unused variable 'j' [-Wunused-variable]
  int i, j;
         ^
memory.cpp:77:3: warning: 'sz' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if(sz==0) return -2;
   ^~
# Verdict Execution time Memory Grader output
1 Correct 2631 ms 283868 KB Output is correct
2 Correct 2843 ms 283896 KB Output is correct
3 Correct 2708 ms 283768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2631 ms 283868 KB Output is correct
2 Correct 2843 ms 283896 KB Output is correct
3 Correct 2708 ms 283768 KB Output is correct
4 Correct 2758 ms 283768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2631 ms 283868 KB Output is correct
2 Correct 2843 ms 283896 KB Output is correct
3 Correct 2708 ms 283768 KB Output is correct
4 Correct 2758 ms 283768 KB Output is correct
5 Correct 2708 ms 284152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2631 ms 283868 KB Output is correct
2 Correct 2843 ms 283896 KB Output is correct
3 Correct 2708 ms 283768 KB Output is correct
4 Correct 2758 ms 283768 KB Output is correct
5 Correct 2708 ms 284152 KB Output is correct
6 Correct 2853 ms 283756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2674 ms 283872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2631 ms 283868 KB Output is correct
2 Correct 2843 ms 283896 KB Output is correct
3 Correct 2708 ms 283768 KB Output is correct
4 Correct 2758 ms 283768 KB Output is correct
5 Correct 2708 ms 284152 KB Output is correct
6 Correct 2853 ms 283756 KB Output is correct
7 Correct 2674 ms 283872 KB Output is correct
8 Correct 2700 ms 283832 KB Output is correct
9 Incorrect 2709 ms 283748 KB Wrong Answer [6]