제출 #1180715

#제출 시각아이디문제언어결과실행 시간메모리
1180715omarrrr코알라 (APIO17_koala)C++20
컴파일 에러
0 ms0 KiB
#include "koala.h" int B[100],R[100],N; int minValue(int n,int w){ for(int i=0;i<n;i++){ B[i]=0; R[i]=0; } B[0]=1; playRound(B,R); for(int i=0;i<n;i++){ if(R[i]==0){ return i; } } } int maxValue(int n,int w){ int tot=n; int x=w/tot; playRound(B,R); while(tot!=1){ tot=0; for(int i=0;i<n;i++){ if(R[i]>x){ tot++; } B[i]=0; } x=w/tot; for(int i=0;i<n;i++){ if(R[i]>x){ B[i]=x; } B[i]=0; } playRound(B,R); } } int greaterValue(int n,int w){ int l=1,r=13,mid; while(l<=r){ mid=(l+r)/2; for(int i=0;i<n;i++){ B[i]=0; R[i]=0; } B[0]=B[1]=mid; playRound(B,R); if(R[0]>R[1]){ return 0; }else if(R[1]>R[0]){ return 1; }else if(R[1]>mid){ l=mid+1; }else{ r=mid-1; } } return 0; } bool cmp(int x,int y){ for(int i=0;i<N;i++){ B[i]=0; } B[x]=B[y]=N; playRound(B,R); return (R[x]>R[y] ? x:y); } void allValues(int n,int w,int* p){ N=n; vector<int>pos(n); for(int i=0;i<n;i++){ pos[i]=i+1; } sort(pos.begin(),pos.end(),cmp); for(int i=0;i<n;i++){ p[pos[i]]=i+1; } }

컴파일 시 표준 에러 (stderr) 메시지

koala.cpp: In function 'int maxValue(int, int)':
koala.cpp:43:1: warning: no return statement in function returning non-void [-Wreturn-type]
   43 | }
      | ^
koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:81:5: error: 'vector' was not declared in this scope
   81 |     vector<int>pos(n);
      |     ^~~~~~
koala.cpp:81:12: error: expected primary-expression before 'int'
   81 |     vector<int>pos(n);
      |            ^~~
koala.cpp:83:9: error: 'pos' was not declared in this scope
   83 |         pos[i]=i+1;
      |         ^~~
koala.cpp:85:10: error: 'pos' was not declared in this scope
   85 |     sort(pos.begin(),pos.end(),cmp);
      |          ^~~
koala.cpp:85:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   85 |     sort(pos.begin(),pos.end(),cmp);
      |     ^~~~
      |     short
koala.cpp: In function 'int minValue(int, int)':
koala.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^