# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336897 | 2020-12-17T07:49:18 Z | seedkin | 올림픽 피자 (tutorial5) | C | 1000 ms | 3052 KB |
#include "pizza.h" struct Order { int next[8]; int prev[8]; int need[8]; int needCnt; int live; }; int order_num; int material[8]; struct Order order[100000]; int root[8]; int last[8]; int check(int need[8], int needCnt) { for(int i =0; i< needCnt; i++) { if(material[need[i]] == 0) return 0; } return 1; } void Init() { order_num = 0; for(int i = 0; i < 8; i++) { material[i] = 0; root[i] = -1; last[i] = -1; } } void Order(int N, int *A) { int r = check(A, N); if(r) { Bake(order_num); order_num++; for(int i =0; i < N; i++) { material[A[i]]--; } return; } order[order_num].needCnt = N; order[order_num].live = 1; for(int i =0; i < N; i++) { order[order_num].need[i] = A[i]; } for(int i = 0; i< 8; i++) { order[order_num].next[i] = -1; order[order_num].prev[i] = -1; } for(int i =0; i < N; i++) { int idx = A[i]; if(root[idx] == -1) { root[idx] = order_num; last[idx] = order_num; order_num++; continue;; } order[last[idx]].next[idx] = order_num; order[order_num].prev[idx] = last[idx]; last[idx] = order_num; } order_num++; return; } void Delivery(int I) { material[I]++; if(root[I] == -1) return; if(material[I] > 1) return; int cur = root[I]; while(cur != -1) { int r = check(order[cur].need, order[cur].needCnt); if(r || order[cur].live == 0) { if(r) Bake(cur); for(int i =0; i < order[cur].needCnt; i++) { material[order[cur].need[i]]--; } if(cur == root[I]) { root[I] = order[cur].next[I]; if( root[I] != -1) order[root[I]].prev[I] = -1; cur = root[I]; continue; } if ( cur == last[I]) { last[I] = order[cur].prev[I]; if(last[I] != -1) order[last[I]].next[I] = -1; break; } order[order[cur].prev[I]].next[I] = order[cur].next[I]; order[order[cur].next[I]].prev[I] = order[cur].prev[I]; } if(material[I] == 0) return; cur = order[cur].next[I]; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 364 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 18 ms | 620 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 45 ms | 3052 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1075 ms | 2652 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |