제출 #1351025

#제출 시각아이디문제언어결과실행 시간메모리
1351025bozho커다란 상품 (IOI17_prize)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "prize.h"
#define endl '\n'
using namespace std;

const int MAX = (2e5) + 5;

int a[MAX][2];
bool d[MAX];

int find_best(int n)
{
    random_device rd;
    mt19937 rng(rd());
    uniform_int_distribution<int> dist(0, n - 1);
    int bx = 0, x = 0, id;
    for (int i = 0; i < 20; i++)
    {
        id = dist(rng);
        if (!d[id])
        {
            a[id] = ask(id);
            d[id] = 1;
            bx = max(bx, a[id][0] + a[id][1]);
        }
    }
    int ans = -1;
    for (int i = 0; i < n; i++)
    {
        if (!d[i])
        {
            a[i] = ask(i);
            d[i] = 1;
        }
        x = a[i][0] + a[i][1];
        if (x == bx)
        {
            int l = i, r = n, mid;
            while (r - l > 1)
            {
                mid = l + (r - l) / 2;
                if(!d[mid])
                {
                    a[mid] = ask(mid);
                    d[i] = 1;
                }
                if(a[i][0] == a[mid][0] && a[i][1] == a[mid][1])
                    l = mid;
                else
                    r = mid;
            }
            i = l;
        }
        else if (x == 0)
        {
            ans = i;
            break;
        }
    }
    return ans;
}

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:22:19: error: incompatible types in assignment of 'std::vector<int>' to 'int [2]'
   22 |             a[id] = ask(id);
      |             ~~~~~~^~~~~~~~~
prize.cpp:32:18: error: incompatible types in assignment of 'std::vector<int>' to 'int [2]'
   32 |             a[i] = ask(i);
      |             ~~~~~^~~~~~~~
prize.cpp:44:28: error: incompatible types in assignment of 'std::vector<int>' to 'int [2]'
   44 |                     a[mid] = ask(mid);
      |                     ~~~~~~~^~~~~~~~~~