Submission #18579

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

using namespace std;

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

void Init() {
	order_num = 0;

}

void Order(int N, int *A) {
	int ordering = 0;
	for (int i = 0; i < N; i++) {
		ordering |= (1 << A[i]);
	}
	if ((ordering & delivered) == ordering) {
		Bake(order_num);
		for (int i = 0; i < 8; i++) {
			if (ordering & (1 << i)) {
				ingred[i]--;
				if (ingred[i] == 0) delivered ^= (1 << i);
			}
		}
	}
	else {
		Q[ordering].push(order_num);
	}
	order_num++;
}

int check(int a)
{
	for (int i = 0; i< 8; ++i) {
		if (((a >> i) & 1) && (ingred[i] == 0)) return 0;
	}
	return 1;
}


void Delivery(int i) {
	ingred[i]++;
	if (ingred[i] == 1) {
		delivered |= (1 << i);
	}
	
	int minidx = -1;
	int min = 99999;
	for (int i = 0; i < 256; i++) {
		if (!Q[i].empty() && check(i)) {
			if (Q[i].front() < min) {
				min = Q[i].front();
				minIdx = i;
			}
		}
	}
	if (minIdx != -1) {
		Bake(Q[minIdx].front());
		Q[min_i].pop();
		for (int i = 0; i < 8; i++) {
			if (min_i & (1 << i)) {
				ingred[i]--;
				if (ingred[i] == 0) delivered ^= (1 << i);
			}
		}
	}
}

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: In function ‘void Delivery(int)’:
tutorial5.cpp:57:5: error: ‘minIdx’ was not declared in this scope
     minIdx = i;
     ^
tutorial5.cpp:61:6: error: ‘minIdx’ was not declared in this scope
  if (minIdx != -1) {
      ^
tutorial5.cpp:63:5: error: ‘min_i’ was not declared in this scope
   Q[min_i].pop();
     ^
tutorial5.cpp:51:6: warning: unused variable ‘minidx’ [-Wunused-variable]
  int minidx = -1;
      ^