# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1155319 | onbert | Lockpicking (IOI23_lockpicking) | C++20 | Compilation error | 0 ms | 0 KiB |
#include <bits/stdc++.h>
using namespace std;
void construct_card(int N, std::vector<int> A, std::vector<std::vector<int>> S);
void define_states(int M, std::vector<int> B, std::vector<std::vector<int>> T, int j0);
const int maxm = 5e4 + 5;
vector<vector<int>> ans(maxm, vector<int>(2, -1));
void construct_card(int n, std::vector<int> A, std::vector<std::vector<int>> S) {
int p[n];
for (int i=0;i<n;i++) p[i] = S[i][0];
vector<int> cyc[n];
bool vis[n];
for (int i=0;i<n;i++) {
int u = i;
while (true) {
vis[u] = true;
cyc[i].push_back(u);
int v = p[u];
if (v == u) break;
}
}
int cnt = -1;
for (int i=0;i<n;i++) {
int sz = cyc[i].size();
cyc[i].resize(30);
for (int j=sz;j<30;j++) cyc[i][j] = cyc[i][j%30];
int cur = 0;
for (int j=0;j<29;j++) {
if (ans[cur][cyc[j]] == -1) {
cnt++;
ans[cur][cyc[j]] = cnt;
}
cur = ans[cur][cyc[j]];
}
ans[cur][cyc[29]] = 0;
}
for (int i=0;i<=m;i++) {
if (ans[i][0] == -1) ans[i][0] = 0;
if (ans[i][1] == -1) ans[i][1] = 0;
}
ans.resize(m);
return ans;
}
Compilation message (stderr)
lockpicking.cpp: In function 'void construct_card(int, std::vector<int>, std::vector<std::vector<int> >)': lockpicking.cpp:30:25: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and 'std::vector<int>') 30 | if (ans[cur][cyc[j]] == -1) { | ^ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from lockpicking.cpp:1: /usr/include/c++/11/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:1043:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ /usr/include/c++/11/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:1061:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ lockpicking.cpp:32:25: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and 'std::vector<int>') 32 | ans[cur][cyc[j]] = cnt; | ^ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from lockpicking.cpp:1: /usr/include/c++/11/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:1043:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ /usr/include/c++/11/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:1061:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ lockpicking.cpp:34:27: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and 'std::vector<int>') 34 | cur = ans[cur][cyc[j]]; | ^ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from lockpicking.cpp:1: /usr/include/c++/11/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:1043:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ /usr/include/c++/11/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:1061:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ lockpicking.cpp:36:17: error: no match for 'operator[]' (operand types are '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} and 'std::vector<int>') 36 | ans[cur][cyc[29]] = 0; | ^ In file included from /usr/include/c++/11/vector:67, from /usr/include/c++/11/functional:62, from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13, from /usr/include/c++/11/algorithm:74, from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65, from lockpicking.cpp:1: /usr/include/c++/11/bits/stl_vector.h:1043:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::reference = int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:1043:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ /usr/include/c++/11/bits/stl_vector.h:1061:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) const [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::const_reference = const int&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:1061:28: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<int>::size_type' {aka 'long unsigned int'} 1061 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ lockpicking.cpp:38:21: error: 'm' was not declared in this scope 38 | for (int i=0;i<=m;i++) { | ^ lockpicking.cpp:42:16: error: 'm' was not declared in this scope 42 | ans.resize(m); | ^ lockpicking.cpp:43:12: error: return-statement with a value, in function returning 'void' [-fpermissive] 43 | return ans; | ^~~