Submission #592524

# Submission time Handle Problem Language Result Execution time Memory
592524 2022-07-09T09:28:52 Z tqbfjotld None (JOI15_memory) C++14
30 / 100
2395 ms 284216 KB
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;

int Memory(int N, int M) {
	if (N>30){			
		int loc = M%(N+1);
		int rem = M/(N+1);
		if (loc==N) return rem==0?-1:-2;
		int res = Get(loc+1);
		if (res=='>'){
			if (rem==0) return -2;
			rem--;
		}
		else{
			rem++;
		}
		return rem*(N+1)+loc+1;
	}
	int loc = M%(N+1);
	int rem = M/(N+1);
	if (loc==0) rem = 1<<15;
	int rems = 15-__builtin_ctz(rem);
	if (rems<0) return -2;
	int remm = rem>>(15-rems+1);
	if (loc==N){
		return rems==0?-1:-2;
	}
	int res = Get(loc+1);
	//printf("loc %d rems = %d remm = %x\n",loc,rems,remm);
	if (res==']' || res=='>'){
		if (rems==0) return -2;
		if ((remm&1)==(res==']')){
			rems--;
			remm>>=1;
		}
		else{
			return -2;
		}
	}
	else{
		if (rems==15){
			return -2;
		}
		rems++;
		remm<<=1;
		remm += (res=='[');
	}
	if ((((remm<<((15-rems)+1))+(1<<(15-rems)))*(N+1)+(loc+1))>=(1<<22))
		return -2;
	//printf("rems = %d, remm = %x\n",rems,remm);
	return ((remm<<((15-rems)+1))+(1<<(15-rems)))*(N+1)+(loc+1);
	
}

# Verdict Execution time Memory Grader output
1 Correct 2133 ms 284116 KB Output is correct
2 Correct 2214 ms 284148 KB Output is correct
3 Correct 2395 ms 283948 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2133 ms 284116 KB Output is correct
2 Correct 2214 ms 284148 KB Output is correct
3 Correct 2395 ms 283948 KB Output is correct
4 Correct 2219 ms 283988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2133 ms 284116 KB Output is correct
2 Correct 2214 ms 284148 KB Output is correct
3 Correct 2395 ms 283948 KB Output is correct
4 Correct 2219 ms 283988 KB Output is correct
5 Correct 2266 ms 284216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2133 ms 284116 KB Output is correct
2 Correct 2214 ms 284148 KB Output is correct
3 Correct 2395 ms 283948 KB Output is correct
4 Correct 2219 ms 283988 KB Output is correct
5 Correct 2266 ms 284216 KB Output is correct
6 Correct 2269 ms 284036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 7304 KB Wrong Answer [1]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2133 ms 284116 KB Output is correct
2 Correct 2214 ms 284148 KB Output is correct
3 Correct 2395 ms 283948 KB Output is correct
4 Correct 2219 ms 283988 KB Output is correct
5 Correct 2266 ms 284216 KB Output is correct
6 Correct 2269 ms 284036 KB Output is correct
7 Incorrect 59 ms 7304 KB Wrong Answer [1]
8 Halted 0 ms 0 KB -