Submission #336899

#TimeUsernameProblemLanguageResultExecution timeMemory
336899seedkin올림픽 피자 (tutorial5)C11
20 / 100
63 ms4972 KiB
#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) { int r = check(order[cur].need, order[cur].needCnt); if(r || order[cur].live == 0) { if(r) { 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]; } if(material[I] == 0) return; cur = order[cur].next[I]; } }

Compilation message (stderr)

grader.c: In function 'main':
grader.c:65:3: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...