답안 #827367

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
827367 2023-08-16T11:52:41 Z vjudge1 Art Collections (BOI22_art) C++17
컴파일 오류
0 ms 0 KB
#include<iostream>
#include<vector>
#include<algorithm>
#include<numeric>
#include"art.h" // Don't forget to uncomment!
typedef vector<int> vi;

/*
int publish(vector<int> R)
{
    for(int& i : R)cout << i << ' ';cout << endl;// COMMENT OUT
    int w;
    cin >> w;
    return w;
}
*/

/*
void answer(vector<int> R)
{
    for(int& i : R)cout << i << ' ';cout << endl;
}
*/

void solve(int N)
{
    vector<int> ans(N);
    iota(ans.begin(), ans.end(), 1ll);
    int w = publish(ans);
    for(int i = 0; i < N; i++)
    {
        int icpy = i;
        for(int j = 0; j < N; ++j)
        {
            if(j == i)continue;
            swap(ans[i], ans[j]);
            int new_w = publish(ans);
            if(new_w == 0)
            {
                answer(ans);
                //return; // maybe comment out? idk
            }
            if(new_w < w)
            {
                w = new_w;
                i = j;
            }
            else swap(ans[i], ans[j]);
        }
        i = icpy;
    }
    answer(ans);

}


/*
int main()
{
    solve(4);
}
*/

Compilation message

art.cpp:6:9: error: 'vector' does not name a type
    6 | typedef vector<int> vi;
      |         ^~~~~~
art.cpp: In function 'void solve(int)':
art.cpp:27:5: error: 'vector' was not declared in this scope
   27 |     vector<int> ans(N);
      |     ^~~~~~
art.cpp:27:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from art.cpp:2:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from art.cpp:2:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
art.cpp:27:12: error: expected primary-expression before 'int'
   27 |     vector<int> ans(N);
      |            ^~~
art.cpp:28:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |     iota(ans.begin(), ans.end(), 1ll);
      |          ^~~
      |          abs
art.cpp:28:5: error: 'iota' was not declared in this scope; did you mean 'std::iota'?
   28 |     iota(ans.begin(), ans.end(), 1ll);
      |     ^~~~
      |     std::iota
In file included from /usr/include/c++/10/numeric:62,
                 from art.cpp:4:
/usr/include/c++/10/bits/stl_numeric.h:88:5: note: 'std::iota' declared here
   88 |     iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
      |     ^~~~
art.cpp:36:13: error: 'swap' was not declared in this scope
   36 |             swap(ans[i], ans[j]);
      |             ^~~~
art.cpp:36:13: note: suggested alternatives:
In file included from /usr/include/c++/10/unordered_map:47,
                 from /usr/include/c++/10/functional:61,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from art.cpp:3:
/usr/include/c++/10/bits/unordered_map.h:2083:5: note:   'std::swap'
 2083 |     swap(unordered_multimap<_Key, _Tp, _Hash, _Pred, _Alloc>& __x,
      |     ^~~~
In file included from /usr/include/c++/10/exception:147,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from art.cpp:1:
/usr/include/c++/10/bits/exception_ptr.h:169:5: note:   'std::__exception_ptr::swap'
  169 |     swap(exception_ptr& __lhs, exception_ptr& __rhs)
      |     ^~~~
In file included from /usr/include/c++/10/bits/nested_exception.h:40,
                 from /usr/include/c++/10/exception:148,
                 from /usr/include/c++/10/ios:39,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from art.cpp:1:
/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'
interface.cpp: In function 'int publish(std::vector<int>)':
interface.cpp:20:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~
interface.cpp: In function 'void answer(std::vector<int>)':
interface.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   36 |     if(v.size() != N) {
      |        ~~~~~~~~~^~~~