Submission #804419

# Submission time Handle Problem Language Result Execution time Memory
804419 2023-08-03T08:37:58 Z vjudge1 Library (JOI18_library) C++17
Compilation error
0 ms 0 KB
#ifdef Home
#define _GLIBCXX_DEBUG
#endif // Home

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

void Solve(int N) {
    srand(time(0));
    vector < int > M(N);
    deque < int > dq;
    vector < int > books(N);
    iota(books.begin(), books.end(), 1);
    random_shuffle(books.begin(), books.end());
    dq.push_back(books.back());
    bool ok = true;
    for(; ok;) {
        ok = false;
        M[dq.back()] = 1;
        for(int i = 0; i < books.size(); ++ i) {
            M[books[i]] = 1;
            int ans = Query(M);
            M[books[i]] = 0;
            if(ans == 1) {
                dq.push_back(books[i]);
                books.erase(books.begin() + i);
                ok = true;
                break;
            }
        }
        M[dq.back()] = 0;
    }
    for(ok = true; ok;) {
        ok = false;
        M[dq.front()] = 1;
        for(int i = 0; i < books.size(); ++ i) {
            M[books[i]] = 1;
            int ans = Query(M);
            M[books[i]] = 0;
            if(ans == 1) {
                dq.push_front(books[i]);
                books.erase(books.begin() + i);
                ok = true;
                break;
            }
        }
        M[dq.front()] = 0;
    }
    vector < int > res;
    for(auto &i : dq) {
        res.push_back(i);
    }
    Answer(res);
}

Compilation message

library.cpp: In function 'void Solve(int)':
library.cpp:24:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int i = 0; i < books.size(); ++ i) {
      |                        ~~^~~~~~~~~~~~~~
library.cpp:26:23: error: 'Query' was not declared in this scope
   26 |             int ans = Query(M);
      |                       ^~~~~
library.cpp:40:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |         for(int i = 0; i < books.size(); ++ i) {
      |                        ~~^~~~~~~~~~~~~~
library.cpp:42:23: error: 'Query' was not declared in this scope
   42 |             int ans = Query(M);
      |                       ^~~~~
library.cpp:57:5: error: 'Answer' was not declared in this scope
   57 |     Answer(res);
      |     ^~~~~~