Submission #11132

# Submission time Handle Problem Language Result Execution time Memory
11132 2014-11-14T16:59:19 Z gs14004 올림픽 피자 (tutorial5) C++
100 / 100
104 ms 16300 KB
///

#include "pizza.h"
#include <deque>
#include <utility>
using namespace std;
typedef pair<int,int> pi;
deque<pi> dq[256];

int order_num;
int ingredients[8], ingnow;

void Init() {
  order_num = 0;
}

int processed[100005];
void deliver(){
    while (1) {
        while (!dq[ingnow].empty() && processed[dq[ingnow].front().first]) {
            dq[ingnow].pop_front();
        }
        if(!dq[ingnow].empty()){
            processed[dq[ingnow].front().first] = 1;
            Bake(dq[ingnow].front().first);
            int t = dq[ingnow].front().second;
            dq[ingnow].pop_front();
            for (int i=0; i<8; i++) {
                if((t>>i)&1){
                    ingredients[i]--;
                    if(ingredients[i] == 0) ingnow ^= (1<<i);
                }
            }
        }
        else break;
    }
}

void Order(int N, int *A) {
    int bitfield = 0;
    for (int i=0; i<N; i++) {
        bitfield |= (1 << A[i]);
    }
    for (int i=0; i<256; i++) {
        if((bitfield & ~i) == 0){
            dq[i].push_back(pi(order_num,bitfield));
        }
    }
    order_num++;
    deliver();
}

void Delivery(int I) {
    ingredients[I]++;
    if(ingredients[I] == 1) ingnow |= (1<<I), deliver();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1780 KB Output is correct
2 Correct 0 ms 1780 KB Output is correct
3 Correct 0 ms 1780 KB Output is correct
4 Correct 0 ms 1780 KB Output is correct
5 Correct 0 ms 1780 KB Output is correct
6 Correct 0 ms 1780 KB Output is correct
7 Correct 0 ms 1780 KB Output is correct
8 Correct 0 ms 1780 KB Output is correct
9 Correct 0 ms 1780 KB Output is correct
10 Correct 0 ms 1780 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 2176 KB Output is correct
2 Correct 4 ms 2176 KB Output is correct
3 Correct 0 ms 2176 KB Output is correct
4 Correct 0 ms 2176 KB Output is correct
5 Correct 8 ms 2176 KB Output is correct
6 Correct 8 ms 2176 KB Output is correct
7 Correct 0 ms 2176 KB Output is correct
8 Correct 4 ms 2176 KB Output is correct
9 Correct 4 ms 2176 KB Output is correct
10 Correct 0 ms 2176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 11812 KB Output is correct
2 Correct 84 ms 14452 KB Output is correct
3 Correct 72 ms 11284 KB Output is correct
4 Correct 88 ms 14848 KB Output is correct
5 Correct 100 ms 16040 KB Output is correct
6 Correct 104 ms 16300 KB Output is correct
7 Correct 56 ms 9964 KB Output is correct
8 Correct 80 ms 15772 KB Output is correct
9 Correct 88 ms 13660 KB Output is correct
10 Correct 52 ms 9436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 11680 KB Output is correct
2 Correct 92 ms 11680 KB Output is correct
3 Correct 92 ms 11680 KB Output is correct
4 Correct 88 ms 11680 KB Output is correct
5 Correct 100 ms 11680 KB Output is correct
6 Correct 92 ms 11680 KB Output is correct
7 Correct 84 ms 11680 KB Output is correct
8 Correct 104 ms 11680 KB Output is correct
9 Correct 96 ms 11680 KB Output is correct
10 Correct 104 ms 11680 KB Output is correct