답안 #73511

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
73511 2018-08-28T11:17:05 Z ics0503 기억 압축 (JOI15_memory) C++17
40 / 100
3378 ms 277016 KB
#include "Memory_lib.h"
#include<stdio.h>
int Memory(int N, int M) {
	if (M > 2000000)return -2;
	if (M < 10000) {
		int now = M / 100 + 1;
		int dep = M % 100;
		if (now > N)return -2;
		char want = Get(now);
		dep += (want == '[' || want == '<') * 2 - 1;
		if (dep < 0 || (now == N && dep != 0))return -2;
		if (now == N)
			return 10000;
		return now * 100 + dep;
	}
	if (M < 20000) {
		int m = M - 10000;
		int now = M-10000 + 1;
		if (now > N)return -2;
		char want = Get(now);
		if (want == '[' || want == '<') {
			return 20000 + (want == '[')*1000000+(now*10000)+(now*100)+1;//go check
		}
		if (now == N)return -1;
		return 10000 + now;
	}
	int m = M - 20000;
	int ck = m / 1000000;
	int nxt = m / 10000 % 100;
	int now = m / 100 % 100;
	int dep = m % 100;
	if (now + 1 > N)return -2;
	char get = Get(now + 1);
	if (get == '[' || get == '<') {
		dep++;
		return 20000 + ck * 1000000 + nxt * 10000 + (now + 1) * 100 + dep;
	}
	dep--;
	if (dep == 0) {
		if (!ck) {
			if (get == ']')return -2;
			return 10000 + nxt;
		}
		else{
			if (get == '>')return -2;
			return 10000 + nxt;
		}
	}
	return 20000 + ck * 1000000 + nxt * 10000 + (now + 1) * 100 + dep;
}

Compilation message

memory.cpp: In function 'int Memory(int, int)':
memory.cpp:17:7: warning: unused variable 'm' [-Wunused-variable]
   int m = M - 10000;
       ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3132 ms 276724 KB Output is correct
2 Correct 2956 ms 276724 KB Output is correct
3 Correct 2731 ms 276960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3132 ms 276724 KB Output is correct
2 Correct 2956 ms 276724 KB Output is correct
3 Correct 2731 ms 276960 KB Output is correct
4 Correct 3378 ms 276960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3132 ms 276724 KB Output is correct
2 Correct 2956 ms 276724 KB Output is correct
3 Correct 2731 ms 276960 KB Output is correct
4 Correct 3378 ms 276960 KB Output is correct
5 Correct 2875 ms 276960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3132 ms 276724 KB Output is correct
2 Correct 2956 ms 276724 KB Output is correct
3 Correct 2731 ms 276960 KB Output is correct
4 Correct 3378 ms 276960 KB Output is correct
5 Correct 2875 ms 276960 KB Output is correct
6 Correct 3186 ms 277016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3038 ms 277016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3132 ms 276724 KB Output is correct
2 Correct 2956 ms 276724 KB Output is correct
3 Correct 2731 ms 276960 KB Output is correct
4 Correct 3378 ms 276960 KB Output is correct
5 Correct 2875 ms 276960 KB Output is correct
6 Correct 3186 ms 277016 KB Output is correct
7 Correct 3038 ms 277016 KB Output is correct
8 Correct 3126 ms 277016 KB Output is correct
9 Incorrect 3162 ms 277016 KB Wrong Answer [6]