답안 #736

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
736 2013-03-01T15:52:53 Z CodingIsHard 올림픽 피자 (tutorial5) C++
컴파일 오류
0 ms 0 KB
#include "pizza.h"
#include <vector>
using namespace std;

int num;
int pos[256] , rest[8];
vector<int> p[256];

void Init() {}

void process(int pizza)
{
    pos[pizza]++;
    for(int i = 0;i < 8;i++)
    {
        if(pizza & (1 << i))
        {
            rest[i]--;
            if(rest[i] == 0)
                can ^= 1 << i;
        }
    }
}

void Order(int N, int *A)
{
    int pizza = 0;
    for(int i = 0;i < N;i++)
        pizza |= 1 << A[i];
    
    p[pizza].push_back(num++);
    if((pizza & can) == pizza)
        process(pizza);
}

void Delivery(int I)
{
    if(!rest[I])
        can |= 1 << I;
    rest[I]++;
    
    do
    {
        int iMin = -1;
        bool con = false;
        for(int i = 1;i < 256;i++)
        {
            if((i & can) == i && pos[i] != v[i].size() && (iMin == -1 || v[i][pos[i]] < v[iMin][pos[iMin]]))
            {
                iMin = i;
                con = true;
            }
        }
        
        if(con)
            process(iMin);
        
    } while (con);
}

Compilation message

tutorial5.cpp: In function 'void process(int)':
tutorial5.cpp:20: error: 'can' was not declared in this scope
tutorial5.cpp: In function 'void Order(int, int*)':
tutorial5.cpp:32: error: 'can' was not declared in this scope
tutorial5.cpp: In function 'void Delivery(int)':
tutorial5.cpp:39: error: 'can' was not declared in this scope
tutorial5.cpp:48: error: 'can' was not declared in this scope
tutorial5.cpp:48: error: 'v' was not declared in this scope
tutorial5.cpp:58: error: 'con' was not declared in this scope