Submission #1079862

# Submission time Handle Problem Language Result Execution time Memory
1079862 2024-08-29T02:45:37 Z Thanhs Library (JOI18_library) C++17
Compilation error
0 ms 0 KB
#include<library.h>
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define double long double
 
#define endl '\n'
#define fastIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define setmin(x, y) x = min((x), (y))
#define setmax(x, y) x = max((x), (y))
#define sqr(x) ((x) * (x))
#define fi first
#define se second
#define aint(x) x.begin(), x.end()
 
// mt19937 hdp(chrono::high_resolution_clock::now().time_since_epoch().count());
// int rand(int l, int r){return l + ((hdp() % (r - l + 1)) + r - l + 1) % (r - l + 1);}

const int NM = 1e5 + 5;
const int mod = 998244353;

vector<int> g[NM];
set<int> s;

int ask(int x, int y)
{
    vector<int> t;
    if (y)
        t.push_back(y);
    auto it = s.begin();
    for (int i = 1; i <= x; i++, it = next(it))
        t.push_back(*it);
    return Query(t);
}

int get(int x)
{
    auto it = s.begin();
    x--;
    while (x--)
        it = next(it);
    return *it;
}

void Solve(int n)
{
    if (n == 1)
    {
        Query(vector<int>(1, 1));
        return;
    }
    for (int i = 1; i <= n; i++)
        s.insert(i);
    for (int i = 1; i <= n; i++)
    {
        s.erase(i);
        while (g[i].size() < 2)
        {
            if (ask(s.size(), i) != ask(s.size(), 0))
                break;
            int l = 0, r = s.size();
            while (l < r - 1)
            {
                int m = l + r >> 1;
                if (ask(m, i) == ask(m, 0))
                    r = m;
                else 
                    l = m;
            }
            g[i].push_back(get(r));
        }
    }
    for (int i = 1; i <= n; i++)
        if (g[i].size() == 1)
            {
                vector<int> res;
                s.insert(i);
                int u = i;
                while (1)
                {
                    res.push_back(u);
                    bool b = 0;
                    for (auto v : g[u])
                        if (s.find(v) == s.end())
                        {
                            b = 1;
                            u = v;
                            break;
                        }
                    if (!b)
                        break;
                }
                Query(res);
                return;
            }
}

Compilation message

library.cpp: In function 'long long int ask(long long int, long long int)':
library.cpp:33:18: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   33 |     return Query(t);
      |                  ^
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: In function 'void Solve(long long int)':
library.cpp:49:15: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   49 |         Query(vector<int>(1, 1));
      |               ^~~~~~~~~~~~~~~~~
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:64:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   64 |                 int m = l + r >> 1;
      |                         ~~^~~
library.cpp:93:23: error: invalid initialization of reference of type 'const std::vector<int>&' from expression of type 'std::vector<long long int>'
   93 |                 Query(res);
      |                       ^~~
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);
      |           ~~~~~~~~~~~~~~~~~~~~~~~~^