Submission #599609

# Submission time Handle Problem Language Result Execution time Memory
599609 2022-07-19T16:38:26 Z joelau None (JOI15_memory) C++14
100 / 100
2442 ms 284176 KB
#include "Memory_lib.h"
#include <bits/stdc++.h>
using namespace std;
 
int Memory(int N, int M) {
	int a = M & ((1<<7)-1); M >>= 7;
	int b = M & ((1<<7)-1); M >>= 7;
	int c = M & ((1<<6)-1); M >>= 6;
	if (M >> 1) {
		M &= 1;
		if (a == N) return -1;
		if (a > N || b >= N || b < a || c > b-a) return -2;
		char ch = Get(b+1);
		if (a == b) {
			if (ch == '<') return (1<<21) | (c<<14) | ((b+1)<<7) | a;
			else if (ch == '[') return (3<<20) | (c<<14) | ((b+1)<<7) | a;
			else return (1<<21) | (c<<14) | ((b+1)<<7) | (a+1);
		}
		else {
			if (ch == '<' || ch == '[') return (1<<21) | (M<<20) | ((c+1)<<14) | ((b+1)<<7) | a;
			if (c > 0) return (1<<21) | (M<<20) | ((c-1)<<14) | ((b+1)<<7) | a;
			if (ch == '>' && M == 1) return -2;
			if (ch == ']' && M == 0) return -2;
			return (1<<21) | ((a+1)<<7) | (a+1);
		}
	}
	else {
		if (a > N) return -2;
		else if (a == N) {
			if (b == 0 && c == 0) return 1<<21;
			else return -2;
		}
		else {
			char ch = Get(a+1);
			if (ch == '<') b++;
			if (ch == '>') b--;
			if (ch == '[') c++;
			if (ch == ']') c--;
			if (b < 0 || c < 0 || b*2 > N || c*2 > N) return -2;
			else return (c<<14) | (b<<7) | (a+1);
		}
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2176 ms 284068 KB Output is correct
2 Correct 2234 ms 284176 KB Output is correct
3 Correct 2250 ms 284128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2176 ms 284068 KB Output is correct
2 Correct 2234 ms 284176 KB Output is correct
3 Correct 2250 ms 284128 KB Output is correct
4 Correct 2167 ms 284020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2176 ms 284068 KB Output is correct
2 Correct 2234 ms 284176 KB Output is correct
3 Correct 2250 ms 284128 KB Output is correct
4 Correct 2167 ms 284020 KB Output is correct
5 Correct 2442 ms 284096 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2176 ms 284068 KB Output is correct
2 Correct 2234 ms 284176 KB Output is correct
3 Correct 2250 ms 284128 KB Output is correct
4 Correct 2167 ms 284020 KB Output is correct
5 Correct 2442 ms 284096 KB Output is correct
6 Correct 2236 ms 283984 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2379 ms 284168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2176 ms 284068 KB Output is correct
2 Correct 2234 ms 284176 KB Output is correct
3 Correct 2250 ms 284128 KB Output is correct
4 Correct 2167 ms 284020 KB Output is correct
5 Correct 2442 ms 284096 KB Output is correct
6 Correct 2236 ms 283984 KB Output is correct
7 Correct 2379 ms 284168 KB Output is correct
8 Correct 2301 ms 284092 KB Output is correct
9 Correct 2249 ms 284032 KB Output is correct