답안 #1017964

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1017964 2024-07-09T12:04:28 Z davit_tsibadze 도서관 (JOI18_library) C++17
컴파일 오류
0 ms 0 KB
#include <library.h>
#include <set>
#include <cmath>
#include <vector>
#include <iomanip>
#include <limits.h>
#include <iostream>
#include <algorithm>
using namespace std;

#define ff first
#define sc second
#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
 
const ll inf = 1e18;
#define int long long
vector <int> ans, m;
void Solve(int N){
    int d;
    while(m.size() < N)m.pb(1);
    for (int i = 1; i <= N; i++){
        m[i - 1] = 0;
        if (Query(m) == 1){d = i; break;}
    }
    vector <int> a, ans; ans.pb(d);
    for (int i = 1; i <= n; i++) if (i != d)a.pb(i);
    while(a.size()){
        int l = 0, r = a.size() - 1, mid;
        while(l < r){
            mid = (l + r) / 2;
            for (int i = 0; i < m.size(); i++)
                m[i] = 0;
            for (int i = 0; i <= mid; i++)
                m[a[i] - 1] = 1;
            int x = Query(m);
            m[ans.back() - 1] = 1;
            int y = Query(m);
            if (x == y)r = mid;
            else l = mid + 1;
        }
        swap(a[l], a[a.size() - 1]);
        ans.pb(a.back()); a.pop_back();
    }
    Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(long long int)':
library.cpp:23:20: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   23 |     while(m.size() < N)m.pb(1);
      |           ~~~~~~~~~^~~
library.cpp:26:19: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   26 |         if (Query(m) == 1){d = i; break;}
      |                   ^
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:29:26: error: 'n' was not declared in this scope
   29 |     for (int i = 1; i <= n; i++) if (i != d)a.pb(i);
      |                          ^
library.cpp:34:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |             for (int i = 0; i < m.size(); i++)
      |                             ~~^~~~~~~~~~
library.cpp:38:27: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   38 |             int x = 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:40:27: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   40 |             int y = 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:47:12: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   47 |     Answer(ans);
      |            ^~~
In file included from library.cpp:1:
library.h:3:37: note: in passing argument 1 of 'void Answer(const std::vector<int>&)'
    3 | void Answer(const std::vector<int>& res);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~