Submission #728950

# Submission time Handle Problem Language Result Execution time Memory
728950 2023-04-23T10:09:25 Z tjd229 None (JOI15_memory) C++14
0 / 100
2204 ms 284216 KB
#include "Memory_lib.h"

int cum[101];
char S[101];
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;
	if (M == 0) for (int i = 1; i <= N; ++i) cum[i] = 0;
	
	S[1 + M] = Get(1 + M);
	if (++M == N) {
		for (int i = 1; i <= N; ++i) {
			if (S[i] == '[' || S[i] == '<') ++cum[i];
			else --cum[i];
			cum[i] += cum[i - 1];
			if (cum[i] < 0) return -2;
		}
		for (int i = 1; i <= N; ++i) {
			if (S[i] == '[' || S[i] == '<') {
				bool c = 0;
				for (int j = i + 1; j <= N && !c; ++j) {
					if (cum[i] == cum[j]) {
						if (S[i] == '[' && S[j] == ']') c = 1;
						else if (S[i] == '<' && S[j] == '>') c = 1;
						else return -2;
					}
				}
			}
		}
		if (cum[N] == 0) return -1;
		else return -2;
	}
	return M;
}
# Verdict Execution time Memory Grader output
1 Correct 2204 ms 284216 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2204 ms 284216 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2204 ms 284216 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2204 ms 284216 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Wrong Answer [3]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2204 ms 284216 KB Output is correct
2 Incorrect 0 ms 212 KB Wrong Answer [3]
3 Halted 0 ms 0 KB -