답안 #608978

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
608978 2022-07-27T11:34:38 Z DeMen100ns Monster Game (JOI21_monster) C++17
컴파일 오류
0 ms 0 KB
/*
Author : DeMen100ns (a.k.a Vo Khac Trieu)
School : VNU-HCM High school for the Gifted
fuck you adhoc
*/

#include <monster.h>

namespace {
    
int cnt(int id, int n){
    int ct = 0;
    for(int i = 0; i < n; ++i){
        if (id == i) continue;
        ct += Query(id, i);
    }
    return ct;
}

};

std::vector<int> Solve(int n)
{
    std::vector<int> v;
    v.push_back(0);

    for(int i = 1; i < n; ++i){
        int l = -1; r = v.size();
        if (l + 1 < r){
            int mid = (l + r) >> 1;
            if (Query(i, v[mid])){
                l = mid;
            } else r = mid;
        }
        v.insert(v.begin() + i, l);
    }
    int ct = 0;
    for(int i = 0; i < n; ++i){
        if (check(i) == n - 2){
            swap(v[ct], v[i]);
            ++ct;
        }
        if (ct == 2) break;
    }
    if (!Query(v[0], v[1])) swap(v[0], v[1]);
    for(int i = 1; i < n - 1; ++i){
        for(int j = i + 1; j < n; ++j){
            if (!Query(i, j)){
                swap(v[i + 1], v[j]);
                break;
            }
        }
    }
    return v;
}

Compilation message

monster.cpp: In function 'std::vector<int> Solve(int)':
monster.cpp:28:21: error: 'r' was not declared in this scope
   28 |         int l = -1; r = v.size();
      |                     ^
monster.cpp:39:13: error: 'check' was not declared in this scope
   39 |         if (check(i) == n - 2){
      |             ^~~~~
monster.cpp:40:13: error: 'swap' was not declared in this scope
   40 |             swap(v[ct], v[i]);
      |             ^~~~
monster.cpp:40:13: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:68,
                 from monster.h:1,
                 from monster.cpp:7:
/usr/include/c++/10/bits/stl_bvector.h:134:3: note:   'std::swap'
  134 |   swap(bool& __x, _Bit_reference __y) noexcept
      |   ^~~~
In file included from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from monster.h:1,
                 from monster.cpp:7:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/new:41,
                 from /usr/include/c++/10/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 from /usr/include/c++/10/vector:64,
                 from monster.h:1,
                 from monster.cpp:7:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
monster.cpp:45:29: error: 'swap' was not declared in this scope
   45 |     if (!Query(v[0], v[1])) swap(v[0], v[1]);
      |                             ^~~~
monster.cpp:45:29: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:68,
                 from monster.h:1,
                 from monster.cpp:7:
/usr/include/c++/10/bits/stl_bvector.h:134:3: note:   'std::swap'
  134 |   swap(bool& __x, _Bit_reference __y) noexcept
      |   ^~~~
In file included from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from monster.h:1,
                 from monster.cpp:7:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/new:41,
                 from /usr/include/c++/10/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 from /usr/include/c++/10/vector:64,
                 from monster.h:1,
                 from monster.cpp:7:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
monster.cpp:49:17: error: 'swap' was not declared in this scope
   49 |                 swap(v[i + 1], v[j]);
      |                 ^~~~
monster.cpp:49:17: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:68,
                 from monster.h:1,
                 from monster.cpp:7:
/usr/include/c++/10/bits/stl_bvector.h:134:3: note:   'std::swap'
  134 |   swap(bool& __x, _Bit_reference __y) noexcept
      |   ^~~~
In file included from /usr/include/c++/10/bits/stl_pair.h:59,
                 from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from monster.h:1,
                 from monster.cpp:7:
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
  189 |     swap(_Tp& __a, _Tp& __b)
      |     ^~~~
/usr/include/c++/10/bits/move.h:189:5: note:   'std::swap'
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/new:41,
                 from /usr/include/c++/10/ext/new_allocator.h:33,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/c++allocator.h:33,
                 from /usr/include/c++/10/bits/allocator.h:46,
                 from /usr/include/c++/10/vector:64,
                 from monster.h:1,
                 from monster.cpp:7:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
monster.cpp: At global scope:
monster.cpp:11:5: warning: 'int {anonymous}::cnt(int, int)' defined but not used [-Wunused-function]
   11 | int cnt(int id, int n){
      |     ^~~