답안 #110580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110580 2019-05-11T08:46:00 Z MAMBA 질문 (CEOI14_question_grader) C++17
100 / 100
1635 ms 79096 KB
#include <bits/stdc++.h>

using namespace std;

#define rep(i , j , k) for (int i = j; i < k; i++)

bool init = false;

constexpr int N = 1000;

int arr[N][6], ptr, ptr2, local[6];

void generate(int me = 0) {
	if (me == 12) {
		if (ptr != 6) return;
		memcpy(arr[ptr2++] , local, sizeof(local));
		return;
	}
	if (ptr < 6) {
		local[ptr++] = me;
		generate(me + 1);
		ptr--;
	}
	generate(me + 1);
}

int decode(int junk , int q, int h) {
	if (!init) {
		generate();
		init = true;
	}
	h--;
	rep(i , 0 , 6)
		if (arr[q][i] == h)
			return true;
	return false;
}

int encode(int junk, int x, int y) {
	if (!init) {
		generate();
		init = true;
	}
	rep(i , 0 , 6) {
		bool shot = false;
		rep(j , 0 , 6)
			if (arr[x][i] == arr[y][j])
				shot  = true;
		if (!shot)
			return arr[x][i] + 1;
	}
}

#include <bits/stdc++.h>

using namespace std;

#define rep(i , j , k) for (int i = j; i < k; i++)

bool init = false;

constexpr int N = 1000;

int arr[N][6], ptr, ptr2, local[6];

void generate(int me = 0) {
	if (me == 12) {
		if (ptr != 6) return;
		memcpy(arr[ptr2++] , local, sizeof(local));
		return;
	}
	if (ptr < 6) {
		local[ptr++] = me;
		generate(me + 1);
		ptr--;
	}
	generate(me + 1);
}

int decode(int junk , int q, int h) {
	if (!init) {
		generate();
		init = true;
	}
	h--;
	rep(i , 0 , 6)
		if (arr[q][i] == h)
			return true;
	return false;
}

int encode(int junk, int x, int y) {
	if (!init) {
		generate();
		init = true;
	}
	rep(i , 0 , 6) {
		bool shot = false;
		rep(j , 0 , 6)
			if (arr[x][i] == arr[y][j])
				shot  = true;
		if (!shot)
			return arr[x][i] + 1;
	}
}

Compilation message

encoder.cpp: In function 'int encode(int, int, int)':
encoder.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

decoder.cpp: In function 'int encode(int, int, int)':
decoder.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1385 ms 78696 KB Output is correct - maxh = 12
2 Correct 1635 ms 79096 KB Output is correct - maxh = 12