답안 #366603

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
366603 2021-02-14T19:20:03 Z idk321 비밀 (JOI14_secret) C++11
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include "secret.h"

const int N = 1000;
int val[N][9];
int* ar;
vector<int> need[N][N];

void cost(int a, int b)
{
    if (a == b)
    {
        need[a][b].push_back(ar[a]);
        return;
    } else if (a == b - 1)
    {
        need[a][a].push_back(ar[a]);
        need[b][b].push_back(ar[b]);
        need[a][b].push_back(ar[a]);
        need[a][b].push_back(ar[b]);
        return;
    }
    int mid = (a + b) / 2;
    vector<int> l(N);
    l[mid] = ar[mid];
    int cur = ar[mid];
    need[mid][mid].push_back(cur);
    for (int i = mid - 1; i >= a; i--)
    {
        cur = Secret(cur, ar[i]);
        need[i][mid].push_back(cur);
    }
    cur = ar[mid + 1];
    need[mid + 1][mid + 1].push_back(cur);
    for (int i = mid + 2; i <= b; i++)
    {
        cur = Secret(cur, ar[i]);
        need[mid + 1][i].push_back(cur);
    }
    for (int i = mid; i >= a; i--)
    {
        for (int j = mid + 1; j <= b; j++)
        {
            need[i][j].push_back(need[i][mid]);
            need[i][j].push_back(need[mid + 1][j]);
        }
    }

    cost(a, mid - 1);
    cost(mid + 1, b);
}

/*
int main()
{

} */


void Init(int n, int A[])
{
    ar = A;
    cost(0, n - 1);
}

int Query(int l, int r)
{
    if (need[l][r].size() == 1) return need[l][r][0];


    return Secret(need[l][r][0], need[l][r][1]);
}

Compilation message

secret.cpp: In function 'void cost(int, int)':
secret.cpp:47:46: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)'
   47 |             need[i][j].push_back(need[i][mid]);
      |                                              ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from secret.cpp:2:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const value_type&' {aka 'const int&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
secret.cpp:48:50: error: no matching function for call to 'std::vector<int>::push_back(std::vector<int>&)'
   48 |             need[i][j].push_back(need[mid + 1][j]);
      |                                                  ^
In file included from /usr/include/c++/9/vector:67,
                 from /usr/include/c++/9/queue:61,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:86,
                 from secret.cpp:2:
/usr/include/c++/9/bits/stl_vector.h:1184:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1184 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1184:35: note:   no known conversion for argument 1 from 'std::vector<int>' to 'const value_type&' {aka 'const int&'}
 1184 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_vector.h:1200:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1200 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/9/bits/stl_vector.h:1200:30: note:   no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1200 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~