제출 #89237

#제출 시각아이디문제언어결과실행 시간메모리
89237zoomswk커다란 상품 (IOI17_prize)C++17
컴파일 에러
0 ms0 KiB
#include "prize.h" #include <vector> #include <algorithm> using namespace std; int m, res; bool flag = false; int solve(int l, int r, int num, int bef){ if(num == 0) return; if(l > r) return; int mid = (l+r)/2; vector<int> resp = ask(mid); if(resp[0]+resp[1] == 0){ res = mid; flag = true; return; } int b = mid; while(resp[0]+resp[1] != m && b < r){ b++; resp = ask(b); if(resp[0]+resp[1] == 0){ res = b; flag = true; return; } } if(resp[0]+resp[1] == m){ solve(l, mid-1, resp[0]-(b-mid)-bef, bef); if(flag) return; solve(b+1, r, num-(resp[0]-bef)); if(flag) return; } else{ solve(l, mid-1, num, bef); } return; } int find_best(int n) { if(n <= 3000){ for(int i=0; i<n; i++){ vector<int> resp = ask(i); if(resp[0]+resp[1] == 0) return i; } } vector<int> resp; for(int i=0; i<500; i++){ resp = ask(i); if(resp[0]+resp[1] == 0) return i; m = max(m, resp[0]+resp[1]); } solve(0, n-1, m, 0); return res; }

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

prize.cpp: In function 'int solve(int, int, int, int)':
prize.cpp:10:18: error: return-statement with no value, in function returning 'int' [-fpermissive]
     if(num == 0) return;
                  ^~~~~~
prize.cpp:11:15: error: return-statement with no value, in function returning 'int' [-fpermissive]
     if(l > r) return;
               ^~~~~~
prize.cpp:17:9: error: return-statement with no value, in function returning 'int' [-fpermissive]
         return;
         ^~~~~~
prize.cpp:26:13: error: return-statement with no value, in function returning 'int' [-fpermissive]
             return;
             ^~~~~~
prize.cpp:31:18: error: return-statement with no value, in function returning 'int' [-fpermissive]
         if(flag) return;
                  ^~~~~~
prize.cpp:32:40: error: too few arguments to function 'int solve(int, int, int, int)'
         solve(b+1, r, num-(resp[0]-bef));
                                        ^
prize.cpp:9:5: note: declared here
 int solve(int l, int r, int num, int bef){
     ^~~~~
prize.cpp:33:18: error: return-statement with no value, in function returning 'int' [-fpermissive]
         if(flag) return;
                  ^~~~~~
prize.cpp:37:5: error: return-statement with no value, in function returning 'int' [-fpermissive]
     return;
     ^~~~~~