답안 #19238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
19238 2016-02-21T14:48:39 Z middleageddr 올림픽 피자 (tutorial5) C++
20 / 100
56 ms 1472 KB
#include "pizza.h"

int order_num;

int remained_tag;
int remained[8];
int order[100000];
int completed_order;

int trans[8] = {
	1, 2, 4, 8, 16, 32, 64, 128
};

int trans2[8];

void Init() {
	int i;
	
	order_num = 0;
	completed_order = 0;

	for (i = 0; i < 100000; i++) {
		order[i] = 0;
	}
	for (i = 0; i < 8; i++) {
		remained[i] = 0;
		trans2[i] = ~trans[i];
	}

	remained_tag = 0;

}

void Order(int N, int *A) {
	int i, j, k, need;

	need = 0;

	for (i = 0; i < N; i++) {
		j = *(A + i);
		need = need | trans[j];
	}

	if ((need & remained_tag) != need) {
		order[order_num] = need;
	}
	else {
		for (i = 0; i < N; i++) {
			j = *(A + i);
			remained[j]--;

			if (!remained[j]) remained_tag = remained_tag & trans2[j];
		}

		Bake(order_num);
		if (completed_order == order_num - 1) completed_order = order_num;
	}

	order_num++;
}


void Delivery(int I) {
	int i, j, k, need;

	remained[I]++;
	if (remained[I] >= 2) return;

	remained_tag = remained_tag | trans[I];
	
	for (i = completed_order + 1; i < order_num; i++) {
		if ((remained_tag & order[i]) == order[i]) {

			for (j = 0; j < 8; j++)
				if (order[i] & trans[j]) {
					remained[j]--;
					if (!remained[j]) remained_tag = remained_tag & trans2[j];
				}

			Bake(i);

			if (completed_order == order_num - 1) completed_order = order_num;

			break;
		}
	}

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 1472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 34 ms 1472 KB Output is correct
2 Correct 43 ms 1472 KB Output is correct
3 Correct 36 ms 1472 KB Output is correct
4 Correct 46 ms 1472 KB Output is correct
5 Correct 41 ms 1472 KB Output is correct
6 Correct 52 ms 1472 KB Output is correct
7 Correct 23 ms 1472 KB Output is correct
8 Correct 48 ms 1472 KB Output is correct
9 Correct 49 ms 1472 KB Output is correct
10 Correct 29 ms 1472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 1472 KB Output isn't correct
2 Halted 0 ms 0 KB -