제출 #1351937

#제출 시각아이디문제언어결과실행 시간메모리
1351937Ice_man커다란 상품 (IOI17_prize)C++20
컴파일 에러
0 ms0 KiB
#include "prize.h"

/**
____    ____    ____    __________________    ____    ____    ____
||I ||  ||c ||  ||e ||  ||                ||  ||M ||  ||a ||  ||n ||
||__||  ||__||  ||__||  ||________________||  ||__||  ||__||  ||__||
|/__\|  |/__\|  |/__\|  |/________________\|  |/__\|  |/__\|  |/__\|

*/

#include <algorithm>
#include <iostream>
#include <vector>
#include <random>

#define PB push_back
#define X first
#define Y second

typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, ll> pil;
typedef std::pair<ll, int> pli;
typedef long double ld;



ll suff[maxn];
ll pref[maxn];
ll res[maxn];

int find_best(int n)
{
    for (int i = 0; i < n; i++)
    {
        suff[i] = 0;
        pref[i] = 0;
        res[i] = 0;
    }

    std::mt19937 rng(69420);
    std::uniform_int_distribution<> dist(0, n - 1);
    int br = 10000;

    while (br--)
    {
        int pos = dist(rng);
        std::vector <int> res = ask(pos);

        pref[i] += res[0];
        suff[i] += res[1];
    }

    ll ss = 0;
    for (int i = 0; i < n; i++)
    {
        res[i] = ss;
        ss += suff[i];
    }

    ss = 0;
    for (int i = n - 1; i >= 0; i++)
    {
        res[i] = ss;
        ss += pref[i];
    }

    for (int i = 0; i < n; i++)
        res[i] = pref[i] + suff[i];

    int maxx = 0;
    for (int i = 1; i < n; i++)
        if (res[i] > res[maxx])
            maxx = i;

    return maxx;
}

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

prize.cpp:29:9: error: 'maxn' was not declared in this scope
   29 | ll suff[maxn];
      |         ^~~~
prize.cpp:30:9: error: 'maxn' was not declared in this scope
   30 | ll pref[maxn];
      |         ^~~~
prize.cpp:31:8: error: 'maxn' was not declared in this scope
   31 | ll res[maxn];
      |        ^~~~
prize.cpp: In function 'int find_best(int)':
prize.cpp:37:9: error: 'suff' was not declared in this scope
   37 |         suff[i] = 0;
      |         ^~~~
prize.cpp:38:9: error: 'pref' was not declared in this scope
   38 |         pref[i] = 0;
      |         ^~~~
prize.cpp:39:9: error: 'res' was not declared in this scope
   39 |         res[i] = 0;
      |         ^~~
prize.cpp:51:9: error: 'pref' was not declared in this scope
   51 |         pref[i] += res[0];
      |         ^~~~
prize.cpp:51:14: error: 'i' was not declared in this scope
   51 |         pref[i] += res[0];
      |              ^
prize.cpp:52:9: error: 'suff' was not declared in this scope
   52 |         suff[i] += res[1];
      |         ^~~~
prize.cpp:58:9: error: 'res' was not declared in this scope
   58 |         res[i] = ss;
      |         ^~~
prize.cpp:59:15: error: 'suff' was not declared in this scope
   59 |         ss += suff[i];
      |               ^~~~
prize.cpp:65:9: error: 'res' was not declared in this scope
   65 |         res[i] = ss;
      |         ^~~
prize.cpp:66:15: error: 'pref' was not declared in this scope
   66 |         ss += pref[i];
      |               ^~~~
prize.cpp:70:9: error: 'res' was not declared in this scope
   70 |         res[i] = pref[i] + suff[i];
      |         ^~~
prize.cpp:70:18: error: 'pref' was not declared in this scope
   70 |         res[i] = pref[i] + suff[i];
      |                  ^~~~
prize.cpp:70:28: error: 'suff' was not declared in this scope
   70 |         res[i] = pref[i] + suff[i];
      |                            ^~~~
prize.cpp:74:13: error: 'res' was not declared in this scope
   74 |         if (res[i] > res[maxx])
      |             ^~~