제출 #1212548

#제출 시각아이디문제언어결과실행 시간메모리
1212548dima2101Super Dango Maker (JOI22_dango3)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "dango3.h"
#define int long long

int GetMax(const std::vector<int> &x, int n, int m)
{
    std::set<int> s;
    for (int i = 1; i <= n * m; i++)
    {
        s.insert(i);
    }
    for (int j : x)
    {
        s.erase(j);
    }
    std::vector<int> now;
    for (int j : s)
    {
        now.push_back(j);
    }
    return m - Query(now);
}

void Solve(int n, int m)
{
    std::vector<std::vector<int>> ans(m);

    for (int i = 1; i <= n * m; i++)
    {
        int l = -1, r = m;
        while (l + 1 < r)
        {
            int mid = (l + r) / 2;
            ans[mid].push_back(i);
            if (GetMax(ans[mid], n, m) == 2)
            {
                l = mid;
            }
            else
            {
                r = mid;
            }
            ans.pop_back();
        }
        assert(r != m);
        ans[r].push_back(i);
    }
    for (int i = 0; i < m; i++)
    {
        Answer(ans[i]);
    }
}

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

dango3.cpp: In function 'long long int GetMax(const std::vector<long long int>&, long long int, long long int)':
dango3.cpp:21:22: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   21 |     return m - Query(now);
      |                      ^~~
In file included from dango3.cpp:2:
dango3.h:5:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    5 | int Query(const std::vector<int> &x);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
dango3.cpp: In function 'void Solve(long long int, long long int)':
dango3.cpp:50:15: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type '__gnu_cxx::__alloc_traits<std::allocator<std::vector<long long int> >, std::vector<long long int> >::value_type' {aka 'std::vector<long long int>'}
   50 |         Answer(ans[i]);
      |         ~~~~~~^~~~~~~~
In file included from dango3.cpp:2:
dango3.h:6:37: note: in passing argument 1 of 'void Answer(const std::vector<int>&)'
    6 | void Answer(const std::vector<int> &a);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^