Submission #18573

# Submission time Handle Problem Language Result Execution time Memory
18573 2016-02-09T13:57:46 Z jjhstop 올림픽 피자 (tutorial5) C++
Compilation error
0 ms 0 KB
#include "pizza.h"
#include <queue>

int order_num;
queue<int> Q[256];
int ingred[9];
int delivered;

void Init() {

  order_num = 0;

}

void check(void)
{
	while (1) {
		int chk = -1;
		for (int i = delivered; i > 0; i--) {
			if (!Q[i].empty() && (chk < 0 || Q[chk].front() > Q[i].front())) chk = i;
		}
		if (chk < 0) return;
		Bake(Q[chk].front()); Q[chk].pop();
		for (int i = 0; i < 8; i++) {
			if (chk & (1 << i)) {
				if (--ingred[i] == 0) delivered ^= (1 << i);
			}
		}

	}
}

void Order(int N, int *A) {
	int ordering = 0;

	for (int i = 0; i < N; i++) {
		ordering |= (1 << A[i]);
	}
	Q[ordering].push(order_num);
	order_num++;
	check();
}

void Delivery(int i) {
	ingred[i]++;
	if (ingred[i] == 1) {
		delivered |= (1 << i);
	}
	check();
}

Compilation message

grader.cpp: In function ‘int main(int, char**)’:
grader.cpp:65:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
tutorial5.cpp:5:1: error: ‘queue’ does not name a type
 queue<int> Q[256];
 ^
tutorial5.cpp: In function ‘void check()’:
tutorial5.cpp:20:9: error: ‘Q’ was not declared in this scope
    if (!Q[i].empty() && (chk < 0 || Q[chk].front() > Q[i].front())) chk = i;
         ^
tutorial5.cpp:23:8: error: ‘Q’ was not declared in this scope
   Bake(Q[chk].front()); Q[chk].pop();
        ^
tutorial5.cpp: In function ‘void Order(int, int*)’:
tutorial5.cpp:39:2: error: ‘Q’ was not declared in this scope
  Q[ordering].push(order_num);
  ^