Submission #1081345

# Submission time Handle Problem Language Result Execution time Memory
1081345 2024-08-30T00:33:10 Z kustizus Library (JOI18_library) C++17
Compilation error
0 ms 0 KB
// #pragma GCC optimize("O3","unroll-loops")
#include <bits/stdc++.h>
#include "library.h"
#include <cstdio>
using namespace std;

// #define 
#define int long long
#define all(v) v.begin(), v.end()
#define fi first
#define se second

mt19937_64 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
// declare
const int N=1e3;
bool vs[N+5];
vector <int> ans;
vector <int> g[N + 5];
void dfs(int i){
    ans.push_back(i);
    vs[i] = true;
    for (int j : g[i])
        if (!vs[j])
            dfs(j);
}
void Solve(int n)
{
    int now = 1;
    for (int i = 1; i < n; i++){
        vector <int> m;
        for (int j = 1; j <= n; ++j)
            if (!vs[j] && now != j)
                m.push_back(j);
        int l = 1, r = m.size();
        while (l < r)
        {
            int md = (l + r) / 2;
            vector <int> ch(n);
            for (int k = l; k <= md; ++k)
                ch[m[k - 1] - 1]=1;
            int c1 = Query(ch);
            ch[now - 1] = 1;
            int c2 = Query(ch);
            if (c1 >= c2) r = md;
            else l = md + 1;
        }
        if (l==m.size())
        {
            vs[now] = 1;
            now = 1;
        }
        else 
        {
            vs[now] = 1;
            g[now].push_back(m[l - 1]);
            g[m[l - 1]].push_back(now);
            now = m[l - 1];
        }
    }
    int idx, mn = 2000;
    for (int i = 1; i <= n; ++i)
        if (g[i].size() <= mn)
        {
            mn = g[i].size();
            idx = i;
        }
    for (int i = 1; i <= n; ++i) vs[i] = false; 
    dfs(idx);
    Answer(ans);
}

Compilation message

library.cpp: In function 'void Solve(long long int)':
library.cpp:41:28: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   41 |             int c1 = Query(ch);
      |                            ^~
In file included from library.cpp:3:
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:43:28: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   43 |             int c2 = Query(ch);
      |                            ^~
In file included from library.cpp:3:
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:14: 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]
   47 |         if (l==m.size())
      |             ~^~~~~~~~~~
library.cpp:62:25: 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]
   62 |         if (g[i].size() <= mn)
      |             ~~~~~~~~~~~~^~~~~
library.cpp:69:12: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   69 |     Answer(ans);
      |            ^~~
In file included from library.cpp:3:
library.h:3:37: note: in passing argument 1 of 'void Answer(const std::vector<int>&)'
    3 | void Answer(const std::vector<int>& res);
      |             ~~~~~~~~~~~~~~~~~~~~~~~~^~~