Submission #593452

# Submission time Handle Problem Language Result Execution time Memory
593452 2022-07-11T08:06:55 Z dantoh000 None (JOI15_memory) C++14
100 / 100
2270 ms 284084 KB
#include "Memory_lib.h"
#include <bits/stdc++.h>
int Memory(int N, int M) {
	int cidx = M&127;
	int idx = (M>>7)&127;
	int ct = (M>>14)&127;
	int type = M>>21;
	///printf("cidx = %d, idx = %d, ct = %d, type = %d\n",cidx,idx,ct,type);
	if (idx > N) return -2;
	if (cidx == 0){
		if (idx == 0){
			idx++;
		}
		else{
			char ch = Get(idx);
			if (ch == '<' || ch == '[') ct++;
			else ct--;
			if (ct < 0) return -2;
			if (idx == N){
				if (ct != 0) return -2;
				else{
					cidx++;
					idx=0;
					ct=0;
					type=0;
				}
			}
			else{
				idx++;
			}
		}
	}
	else if (cidx <= N){
		if (idx == 0){
			char ch = Get(cidx);
			if (ch == '>' || ch == ']'){
				cidx = cidx+1;
			}
			else{
				idx = cidx+1;
				ct = 1;
				type = (ch=='<')?1:0;
			}
		}
		else{
			char ch = Get(idx);
			if (ch == '>' || ch == ']') {
				ct--;
				idx++;
				if (ct < 0) return -2;
				if (ct == 0){
					if ((ch=='>')==type){
						cidx++;
						idx=0;
						ct=0;
						type=0;
					}
					else return -2;
				}
			}
			else {
				ct++;
				idx++;
			}
		}
	}
	else return -1;
	///printf("new %d %d %d %d\n",cidx,idx,ct,type);
	M = (type<<21)|(ct<<14)|(idx<<7)|cidx;
	///printf("%d\n",M);
	return M;

}
# Verdict Execution time Memory Grader output
1 Correct 2149 ms 284056 KB Output is correct
2 Correct 2155 ms 284060 KB Output is correct
3 Correct 2138 ms 284028 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2149 ms 284056 KB Output is correct
2 Correct 2155 ms 284060 KB Output is correct
3 Correct 2138 ms 284028 KB Output is correct
4 Correct 2114 ms 284052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2149 ms 284056 KB Output is correct
2 Correct 2155 ms 284060 KB Output is correct
3 Correct 2138 ms 284028 KB Output is correct
4 Correct 2114 ms 284052 KB Output is correct
5 Correct 2210 ms 284084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2149 ms 284056 KB Output is correct
2 Correct 2155 ms 284060 KB Output is correct
3 Correct 2138 ms 284028 KB Output is correct
4 Correct 2114 ms 284052 KB Output is correct
5 Correct 2210 ms 284084 KB Output is correct
6 Correct 2237 ms 283964 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2267 ms 283972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2149 ms 284056 KB Output is correct
2 Correct 2155 ms 284060 KB Output is correct
3 Correct 2138 ms 284028 KB Output is correct
4 Correct 2114 ms 284052 KB Output is correct
5 Correct 2210 ms 284084 KB Output is correct
6 Correct 2237 ms 283964 KB Output is correct
7 Correct 2267 ms 283972 KB Output is correct
8 Correct 2270 ms 284056 KB Output is correct
9 Correct 2224 ms 283904 KB Output is correct