답안 #1060895

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1060895 2024-08-16T04:12:39 Z onbert 커다란 상품 (IOI17_prize) C++17
컴파일 오류
0 ms 0 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5;
vector<int> vals[maxn];
vector<int> qry(int i) {
    if (vals[i].first!=-1) return vals[i];
    else return vals[i] = ask(i);
}
int find_best(int n) {
    for (int i=0;i<n;i++) vals[i] = {-1, -1};
    for (int i=0;i<n;i++) {
        vector<int> x = qry(i);
        if (x[0] + x[1] == 0) return i;
        int l = i, r = n-1;
        while (l<r) {
            int mid = (l+r)/2;
            vector<int> y = qry(mid);
            if (y[0]+y[1]==0) return y;
            if (y[0]!=x[0] || y[1]!=x[1]) r = mid-1;
            else l = mid;
        }
        i = l;
    }
}

Compilation message

prize.cpp: In function 'std::vector<int> qry(int)':
prize.cpp:7:17: error: 'class std::vector<int>' has no member named 'first'
    7 |     if (vals[i].first!=-1) return vals[i];
      |                 ^~~~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:19:38: error: cannot convert 'std::vector<int>' to 'int' in return
   19 |             if (y[0]+y[1]==0) return y;
      |                                      ^
prize.cpp: In function 'std::vector<int> qry(int)':
prize.cpp:9:1: warning: control reaches end of non-void function [-Wreturn-type]
    9 | }
      | ^