Submission #337583

#TimeUsernameProblemLanguageResultExecution timeMemory
337583seedkin올림픽 피자 (tutorial5)C11
100 / 100
78 ms3436 KiB
#include "pizza.h" struct Order { int next; int needCnt; int need[8]; }; int order_num; int material[8]; int allMate; struct Order order[100000]; int root[256]; int last[256]; int makeMate(int N, int *A) { int r = 0; for(int i =0;i < N; i++) { r |= (1 << A[i]); } return r; } void mergeMate() { int r = 0; for(int i =0 ;i < 8; i++) { if(material[i]) r |= (1 << i); } allMate = r; } void Init() { order_num = 0; for(int i =0; i < 256; i ++) { root[i] = -1; last[i] = -1; } allMate = 0; for(int i = 0; i < 8; i++) { material[i] = 0; } } void Order(int N, int *A) { int idx = makeMate(N, A); if( (allMate & idx) == idx) { Bake(order_num); order_num++; for(int i =0; i < N; i++) { material[A[i]]--; } mergeMate(); return; } order[order_num].needCnt = N; for(int i =0; i < N; i++) { order[order_num].need[i] = A[i]; } order[order_num].next = -1; if(root[idx] == -1) { root[idx] = order_num; last[idx] = order_num; order_num++; return; } order[last[idx]].next = order_num; last[idx] = order_num; order_num++; return; } void Delivery(int I) { material[I]++; if(material[I] > 1) return; mergeMate(); int targetNum = 1e8; int targetMate = 0; for(int i = 0; i < 256; i++) { if(root[i] == -1) continue; if( (allMate & i) != i) continue; if(targetNum > root[i] ) { targetMate = i; targetNum = root[i]; } } if (targetNum == 1e8) return; Bake(targetNum); root[targetMate] = order[targetNum].next; for(int i =0; i < order[targetNum].needCnt; i++) { material[order[targetNum].need[i]]--; } mergeMate(); }

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...