# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
336908 | 2020-12-17T08:58:42 Z | seedkin | 올림픽 피자 (tutorial5) | C | 1000 ms | 4972 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; 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) { if(material[I] == 0) return; int r = check(order[cur].need, order[cur].needCnt); if(r || order[cur].live == 0) { if(r && order[cur].live) { Bake(cur); order[cur].live = 0; 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]; } cur = order[cur].next[I]; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 0 ms | 364 KB | Output is correct |
4 | Correct | 0 ms | 364 KB | Output is correct |
5 | Correct | 0 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 0 ms | 364 KB | Output is correct |
9 | Correct | 0 ms | 364 KB | Output is correct |
10 | Correct | 0 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 18 ms | 620 KB | Output is correct |
2 | Correct | 17 ms | 620 KB | Output is correct |
3 | Correct | 17 ms | 620 KB | Output is correct |
4 | Correct | 17 ms | 620 KB | Output is correct |
5 | Correct | 17 ms | 620 KB | Output is correct |
6 | Correct | 17 ms | 640 KB | Output is correct |
7 | Correct | 17 ms | 620 KB | Output is correct |
8 | Correct | 17 ms | 640 KB | Output is correct |
9 | Correct | 16 ms | 620 KB | Output is correct |
10 | Correct | 18 ms | 620 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 46 ms | 3052 KB | Output is correct |
2 | Correct | 48 ms | 4204 KB | Output is correct |
3 | Correct | 42 ms | 2796 KB | Output is correct |
4 | Correct | 50 ms | 4460 KB | Output is correct |
5 | Correct | 50 ms | 4972 KB | Output is correct |
6 | Correct | 50 ms | 4960 KB | Output is correct |
7 | Correct | 38 ms | 2156 KB | Output is correct |
8 | Correct | 50 ms | 4844 KB | Output is correct |
9 | Correct | 45 ms | 3820 KB | Output is correct |
10 | Correct | 38 ms | 2156 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 2688 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |