답안 #1080179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080179 2024-08-29T07:49:31 Z KhoaDuy 도서관 (JOI18_library) C++14
컴파일 오류
0 ms 0 KB
#include "library.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#define endl '\n'
void solve(int n){
    vector<int> m(n,0);
    vector<vector<int>> inter;
    int input;
    for(int i=0;i<n;i++){
        m[i]=1;
        input=Query(m);
        if(input!=i+1){
            break;
        }
        inter.push_back(i);
    }
    for(int k=inter.size();k<n;k++){
        int low=0,high=inter.size()-1;
        low--,high++;
        while(high-low>1){
            int mid=((high-low)>>1)+low;
            fill(m.begin(),m.end(),0);
            m[k]=1;
            for(int i=0;i<=mid;i++){
                for(int x:inter[i]){
                    m[x]=1;
                }
            }
            input=Query(m);
            if(input<mid+2){
                high=mid;
            }
            else{
                low=mid;
            }
        }
        if(high==inter.size()){
            inter.push_back(k);
            continue;
        }
        fill(m.begin(),m.end(),0);
        m[k]=1,m[inter[high][0]]=1;
        input=Query(m);
        if(input==1){
            inter[high].insert(inter[high].begin(),k);
        }
        else{
            inter[high].push_back(k);
        }
        int l=high;
        if(l<inter.size()-1){
            low=l+1,high=inter.size()-1;
            low--,high++;
            while(high-low>1){
                int mid=((high-low)>>1)+low;
                fill(m.begin(),m.end(),0);
                m[k]=1;
                for(int i=l+1;i<=mid;i++){
                    for(int x:inter[i]){
                        m[x]=1;
                    }
                }
                input=Query(m);
                if(input<mid-l+1){
                    high=mid;
                }
                else{
                    low=mid;
                }
            }
            if(high<inter.size()){
                fill(m.begin(),m.end(),0);
                m[k]=1;
                m[inter[high][0]]=1;
                input=Query(m);
                if(inter[l][0]==k){
                    vector<int> temp;
                    if(input==1){

                    }
                    else{
                        for(int x:inter[high]){
                            temp.push_back(x);
                        }
                        for(int x:inter[l]){
                            temp.push_back(x);
                        }
                        inter[high]=temp;
                        auto it=inter.begin()+l;
                        inter.erase(it);
                    }
                }
                else{
                    if(input==1){

                    }
                    else{

                    }
                }
            }
        }
    }
}
signed main(){
    
}

Compilation message

library.cpp: In function 'void solve(long long int)':
library.cpp:12:21: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   12 |         input=Query(m);
      |                     ^
In file included from library.cpp:1:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp:16:26: error: no matching function for call to 'std::vector<std::vector<long long int> >::push_back(long long int&)'
   16 |         inter.push_back(i);
      |                          ^
In file included from /usr/include/c++/10/vector:67,
                 from library.h:1,
                 from library.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'long long int' to 'const value_type&' {aka 'const std::vector<long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'long long int' to 'std::vector<std::vector<long long int> >::value_type&&' {aka 'std::vector<long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
library.cpp:30:25: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   30 |             input=Query(m);
      |                         ^
In file included from library.cpp:1:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp:38:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if(high==inter.size()){
      |            ~~~~^~~~~~~~~~~~~~
library.cpp:39:30: error: no matching function for call to 'std::vector<std::vector<long long int> >::push_back(long long int&)'
   39 |             inter.push_back(k);
      |                              ^
In file included from /usr/include/c++/10/vector:67,
                 from library.h:1,
                 from library.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from 'long long int' to 'const value_type&' {aka 'const std::vector<long long int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<long long int>; _Alloc = std::allocator<std::vector<long long int> >; std::vector<_Tp, _Alloc>::value_type = std::vector<long long int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from 'long long int' to 'std::vector<std::vector<long long int> >::value_type&&' {aka 'std::vector<long long int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
library.cpp:44:21: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   44 |         input=Query(m);
      |                     ^
In file included from library.cpp:1:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp:52:13: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         if(l<inter.size()-1){
      |            ~^~~~~~~~~~~~~~~
library.cpp:64:29: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   64 |                 input=Query(m);
      |                             ^
In file included from library.cpp:1:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^
library.cpp:72:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |             if(high<inter.size()){
      |                ~~~~^~~~~~~~~~~~~
library.cpp:76:29: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   76 |                 input=Query(m);
      |                             ^
In file included from library.cpp:1:
library.h:2:35: note: in passing argument 1 of 'int Query(const std::vector<int>&)'
    2 | int Query(const std::vector<int>& M);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^