| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1310746 | theiulius | 동굴 (IOI13_cave) | C++20 | 컴파일 에러 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
#include "cave.h"
void exploreCave(int N) {
int n = N;
vector<int> a[n] = {}, b[n] = {};
vector<int> used(n, 0); // which switches are already fixed
for (int i = 0; i < n; i++){
b[i] = -1;
}
for (int i = 0; i < n; ++i) {
// set all unused switches to 0
for (int j = 0; j < n; ++j) if (!used[j]) a[j] = 0;
int x = tryCombination(a);
int berk = (x > i || x == -1) ? 0 : 1;
// build list of unused switches
vector<int> unused;
for (int j = 0; j < n; ++j) if (!used[j]) unused.push_back(j);
// binary search over unused switches
int L = 0, R = (int)unused.size() - 1;
int pos = -1;
while (L <= R) {
int mid = (L + R) / 2;
for (int k = 0; k <= mid; ++k) a[unused[k]] = berk;
for (int k = mid + 1; k < (int)unused.size(); ++k) a[unused[k]] = 1 ^ berk;
x = tryCombination(a);
if (x > i || x == -1) {
pos = mid;
R = mid - 1;
} else {
L = mid + 1;
}
}
int ans = unused[pos];
b[ans] = i;
used[ans] = 1;
a[ans] = berk; // fix this switch permanently
}
answer(a, b);
}
// main(){
// exploreCave(5);
// }
컴파일 시 표준 에러 (stderr) 메시지
cave.cpp: In function 'void exploreCave(long long int)':
cave.cpp:11:15: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'int')
11 | b[i] = -1;
| ^
In file included from /usr/include/c++/13/vector:72,
from /usr/include/c++/13/functional:64,
from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53,
from cave.cpp:1:
/usr/include/c++/13/bits/vector.tcc:210:5: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'int' to 'const std::vector<long long int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
In file included from /usr/include/c++/13/vector:66:
/usr/include/c++/13/bits/stl_vector.h:766:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'int' to 'std::vector<long long int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:788:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<long long int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
cave.cpp:16:58: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'int')
16 | for (int j = 0; j < n; ++j) if (!used[j]) a[j] = 0;
| ^
/usr/include/c++/13/bits/vector.tcc:210:5: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'int' to 'const std::vector<long long int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:766:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'int' to 'std::vector<long long int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:788:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<long long int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
cave.cpp:18:32: error: cannot convert 'std::vector<long long int>*' to 'long long int*'
18 | int x = tryCombination(a);
| ^
| |
| std::vector<long long int>*
In file included from cave.cpp:4:
cave.h:8:24: note: initializing argument 1 of 'long long int tryCombination(long long int*)'
8 | int tryCombination(int S[]);
cave.cpp:30:59: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'long long int')
30 | for (int k = 0; k <= mid; ++k) a[unused[k]] = berk;
| ^~~~
/usr/include/c++/13/bits/vector.tcc:210:5: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'long long int' to 'const std::vector<long long int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:766:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'long long int' to 'std::vector<long long int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:788:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
cave.cpp:31:83: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'long long int')
31 | for (int k = mid + 1; k < (int)unused.size(); ++k) a[unused[k]] = 1 ^ berk;
| ^~~~
/usr/include/c++/13/bits/vector.tcc:210:5: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'long long int' to 'const std::vector<long long int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:766:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'long long int' to 'std::vector<long long int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:788:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
cave.cpp:33:32: error: cannot convert 'std::vector<long long int>*' to 'long long int*'
33 | x = tryCombination(a);
| ^
| |
| std::vector<long long int>*
cave.h:8:24: note: initializing argument 1 of 'long long int tryCombination(long long int*)'
8 | int tryCombination(int S[]);
cave.cpp:43:18: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'long long int')
43 | b[ans] = i;
| ^
/usr/include/c++/13/bits/vector.tcc:210:5: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'long long int' to 'const std::vector<long long int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:766:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'long long int' to 'std::vector<long long int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:788:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
cave.cpp:45:18: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'long long int')
45 | a[ans] = berk; // fix this switch permanently
| ^~~~
/usr/include/c++/13/bits/vector.tcc:210:5: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
210 | vector<_Tp, _Alloc>::
| ^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/vector.tcc:211:42: note: no known conversion for argument 1 from 'long long int' to 'const std::vector<long long int>&'
211 | operator=(const vector<_Tp, _Alloc>& __x)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:766:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:766:26: note: no known conversion for argument 1 from 'long long int' to 'std::vector<long long int>&&'
766 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move())
| ~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:788:7: note: candidate: 'constexpr std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]'
788 | operator=(initializer_list<value_type> __l)
| ^~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:788:46: note: no known conversion for argument 1 from 'long long int' to 'std::initializer_list<long long int>'
788 | operator=(initializer_list<value_type> __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
cave.cpp:48:12: error: cannot convert 'std::vector<long long int>*' to 'long long int*'
48 | answer(a, b);
| ^
| |
| std::vector<long long int>*
cave.h:9:17: note: initializing argument 1 of 'void answer(long long int*, long long int*)'
9 | void answer(int S[], int D[]);