답안 #41854

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
41854 2018-02-21T15:24:39 Z rahasia 커다란 상품 (IOI17_prize) C++14
컴파일 오류
0 ms 0 KB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

#define repU(x, y) for(int i = x; i <= y; ++i)
#define mp make_pair
#define pb push_back
#define allV(x) x.begin(), x.end()
#define fi first
#define se second

typedef long long LL;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef vector< LL > vL;
typedef vector< vL > vvL;
typedef vector< bool > vb;

// GLOBAL
vi asked[200002];

int SUM = -1;
// --

vi toAsk(int i) {
    if (asked[i].size() == 0)
        asked[i] = ask(i);
    return asked[i];
}

int foo(int le, int ri) {
    if (le > ri) return -1;

    int mid1 = (le + ri) / 2, mid2 = mid1+1;

    vi tmp = toAsk(mid1);
    while (tmp[0] + tmp[1] != SUM && le <= mid1) {
        if (tmp[0] == 0 && tmp[1] == 0)
            return mid1;

        tmp = toAsk(--mid1);
    }

    tmp = toAsk(mid2);
    while (tmp[0] + tmp[1] != SUM && mid2 <= ri) {
        if (tmp[0] == 0 && tmp[1] == 0)
            return mid2;

        tmp = toAsk(++mid2);
    }

    int res = foo(le, mid1);
    if (res != -1) return res;

    return foo(mid2, ri);
}

int find_best(int n) {
    if (n <= 5) {
        vi tmp;
        repU(0, n-1) {
            tmp = toAsk(i);
            if (tmp[0] == 0 && tmp[1] == 0)
                return i;
        }
        return -1;
    }
    else {
        repU(0, min(N-1, 500)) {
            vi tmp = toAsk(i);
            SUM = max(SUM, tmp[0] + tmp[1]);
        }

        return foo(0, n-1);
    }
}

Compilation message

prize.cpp: In function 'int find_best(int)':
prize.cpp:71:21: error: 'N' was not declared in this scope
         repU(0, min(N-1, 500)) {
                     ^
prize.cpp:5:40: note: in definition of macro 'repU'
 #define repU(x, y) for(int i = x; i <= y; ++i)
                                        ^