Submission #728939

# Submission time Handle Problem Language Result Execution time Memory
728939 2023-04-23T09:55:45 Z tjd229 None (JOI15_memory) C++14
100 / 100
2479 ms 284252 KB
#include "Memory_lib.h"
 
char S[123];
int concat(int l, int r, int op, int mode) {
	return mode + (op << 1) + (r << 8) + (l << 15);
}
int Memory(int N, int M) {
 
	if (N & 1) return -2;
	int sq6 = 64;
	int sq7 = 128;
	int mode = M & 1; M >>= 1;
	int op = M & (sq7 - 1); M >>= 7;
	int r = M & (sq7 - 1); // i
	int l = M >> 7; //j
	//printf("%d,%d,%d,%d\n",l,r,op,mode);
	if (r == N)
		return op ? -2 : -1;
 
	if (l >= N) return -2;
 
	char c = Get(l + 1);
	if (l == r) {
		++l;
		if (c == ']' || c == '>') {
			if (--op < 0) return -2;
			return concat(l, ++r, op, mode);
		}
		else {
			mode = (c == '[') + 0;
			op = 1;
			return concat(l, r, op, mode);
		}
	}
	else {
		switch (c) {
		case '<':case '[':
			++op;
			break;
		case '>':
			--op;
			if (op < 0) return -2;
			if (l > r && op == 0) {
				if (mode != 0) return -2;
				return concat(0, ++r, op, 0);
			}
			break;
		case ']':
			--op;
			if (op < 0) return -2;
			if (l > r && op == 0) {
				if (mode != 1) return -2;
				return concat(0, ++r, op, 0);
			}
			break;
		}
		++l;
	}
	//op>50 chk
	if (op > (N >> 1)) return -2;
	return concat(l, r, op, mode);
}

Compilation message

memory.cpp: In function 'int Memory(int, int)':
memory.cpp:10:6: warning: unused variable 'sq6' [-Wunused-variable]
   10 |  int sq6 = 64;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 2298 ms 284252 KB Output is correct
2 Correct 2369 ms 284108 KB Output is correct
3 Correct 2322 ms 284152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2298 ms 284252 KB Output is correct
2 Correct 2369 ms 284108 KB Output is correct
3 Correct 2322 ms 284152 KB Output is correct
4 Correct 2292 ms 284008 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2298 ms 284252 KB Output is correct
2 Correct 2369 ms 284108 KB Output is correct
3 Correct 2322 ms 284152 KB Output is correct
4 Correct 2292 ms 284008 KB Output is correct
5 Correct 2235 ms 284176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2298 ms 284252 KB Output is correct
2 Correct 2369 ms 284108 KB Output is correct
3 Correct 2322 ms 284152 KB Output is correct
4 Correct 2292 ms 284008 KB Output is correct
5 Correct 2235 ms 284176 KB Output is correct
6 Correct 2205 ms 283964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2381 ms 284224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2298 ms 284252 KB Output is correct
2 Correct 2369 ms 284108 KB Output is correct
3 Correct 2322 ms 284152 KB Output is correct
4 Correct 2292 ms 284008 KB Output is correct
5 Correct 2235 ms 284176 KB Output is correct
6 Correct 2205 ms 283964 KB Output is correct
7 Correct 2381 ms 284224 KB Output is correct
8 Correct 2479 ms 284016 KB Output is correct
9 Correct 2354 ms 284068 KB Output is correct