제출 #390570

#제출 시각아이디문제언어결과실행 시간메모리
390570faresbasbs커다란 상품 (IOI17_prize)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; /*vector<int> ask(int pos){ cout << pos << endl; int a,b; cin >> a >> b; vector<int> ret = {a,b}; return ret; }*/ int find_best(int n){ int sum = 0; for(int i = 0 ; i < 500 ; i += 1){ vector<int> v = ask(rand()%n); sum = max(sum,v[0]+v[1]); if(v[0]+){ } } vector<pair<int,vector<int>>> v; int p = 0; while(p < n){ while(p < n){ vector<int> f = ask(p); if(f[0]+f[1] == sum){ v.push_back({p,f}); break; }else{ if(f[0]+f[1] == 0){ return p; } p += 1; } } p += 500; } v.push_back({n,{sum,0}}); for(int i = 0 ; i+1 < v.size() ; i += 1){ while(v[i+1].second[0] != v[i].second[0]){ int first = v[i].first , last = v[i+1].first; while(last-first > 1){ int mid = (first+last)/2; vector<int> f = ask(mid); if(f[0]+f[1] == 0){ return mid; } if(f[0]+f[1] == sum && f[0] == v[i].second[0]){ first = mid; }else{ last = mid; } } vector<int> f; for(int j = first+2 ; j < n ; j += 1){ f = ask(j); if(f[0]+f[1] == 0){ return j; } if(f[0]+f[1] == sum){ v[i] = {j,f}; break; } } } } } /*int main(){ cout << find_best(8) << endl; }*/

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:18:17: error: expected primary-expression before ')' token
   18 |         if(v[0]+){
      |                 ^
prize.cpp:40:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::vector<int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for(int i = 0 ; i+1 < v.size() ; i += 1){
      |                     ~~~~^~~~~~~~~~
prize.cpp:22:35: warning: control reaches end of non-void function [-Wreturn-type]
   22 |     vector<pair<int,vector<int>>> v;
      |                                   ^