제출 #297997

#제출 시각아이디문제언어결과실행 시간메모리
297997Batyr커다란 상품 (IOI17_prize)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; #define pb push_back #define ss second #define ff first #define pii pair<int,int> const int maxn=2e5+5; int dp[maxn][3],ans; bool tr; pii f(int l,int r){ if(dp[l][0] == -1 and dp[l][1]==-1){ vector<int> p = ask(l); dp[l][0]=p[0]; dp[l][1]=p[1]; } if(dp[l][0]+dp[l][1]==0){ ans=l,tr=1; return; } if(dp[r][0]==-1 and dp[r][1]==-1){ vector<int> p = ask(r); dp[r][0] = p[0]; dp[r][1] = p[1]; } if(dp[r][0]+dp[r][1]==0){ ans = r,tr=1; return; } if(dp[l][0]+dp[l][1] == dp[r][0]+dp[r][1] and dp[r][0]-dp[l][0]==0) return; f(l,(l+r)/2); if(tr) return; f((l+r)/2+1,r); if(tr) return; } int find_best(int n){ memset(dp,-1,sizeof(dp)); f(0,n-1); return ans; }

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

prize.cpp: In function 'std::pair<int, int> f(int, int)':
prize.cpp:21:3: error: return-statement with no value, in function returning 'std::pair<int, int>' [-fpermissive]
   21 |   return;
      |   ^~~~~~
prize.cpp:31:3: error: return-statement with no value, in function returning 'std::pair<int, int>' [-fpermissive]
   31 |   return;
      |   ^~~~~~
prize.cpp:34:70: error: return-statement with no value, in function returning 'std::pair<int, int>' [-fpermissive]
   34 |  if(dp[l][0]+dp[l][1] == dp[r][0]+dp[r][1] and dp[r][0]-dp[l][0]==0) return;
      |                                                                      ^~~~~~
prize.cpp:37:9: error: return-statement with no value, in function returning 'std::pair<int, int>' [-fpermissive]
   37 |  if(tr) return;
      |         ^~~~~~
prize.cpp:39:9: error: return-statement with no value, in function returning 'std::pair<int, int>' [-fpermissive]
   39 |  if(tr) return;
      |         ^~~~~~
prize.cpp:40:1: warning: control reaches end of non-void function [-Wreturn-type]
   40 | }
      | ^