답안 #1079886

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079886 2024-08-29T03:01:01 Z Thanhs 도서관 (JOI18_library) C++14
컴파일 오류
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 = 1e3 + 5;

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

// int Query(vector<int>& v)
// {
//     cout << "? ";
//     for (int t : v)
//         cout << t << ' ';
//     cout << endl;
//     int res;
//     cin >> res;
//     return res;
// }

// void Answer(vector<int>& v)
// {
//     cout << "! ";
//     for (int t : v)
//         cout << t << ' ';
//     cout << endl;
// }

int Query(vector<int>& v){}

void Answer(vector<int>& v){}

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)
    {
        vector<int> t(1, 1);
        Answer(t);
        return;
    }
    for (int i = 1; i <= n; i++)
        s.insert(i);
    for (int i = 1; i <= n; i++)
    {
        vector<int> tmp;
        s.erase(i);
        if (s.empty())
            break;
        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;
            }
            int t = get(r);
            g[i].push_back(t);
            g[t].push_back(i);
            tmp.push_back(t);
            s.erase(t);
        }
        for (int t : tmp)
            s.insert(t);
    }
    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;
                    }
                s.insert(u);
                if (!b)
                    break;
            }
            Answer(res);
            return;
        }
}

int main()
{
    int n;
    cin >> n;
    Solve(n);
}

Compilation message

library.cpp: In function 'int Query(std::vector<int>&)':
library.cpp:43:27: warning: no return statement in function returning non-void [-Wreturn-type]
   43 | int Query(vector<int>& v){}
      |                           ^
library.cpp: In function 'void Solve(int)':
library.cpp:90:27: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   90 |                 int m = l + r >> 1;
      |                         ~~^~~
/usr/bin/ld: /tmp/ccRXeasc.o: in function `main':
library.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccclGGKd.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status