# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1179545 | Gr1sen | 던전 (IOI21_dungeons) | C++20 | Compilation error | 0 ms | 0 KiB |
#include "dungeons.h"
#include <vector>
#include<iomanip>
#include<algorithm>
using namespace std;
#define ll long long
#define vi vector<ll>
int n;
vi S, P, W, L;
vi M, M2, M3;
ll oinkoink(int p) {
if (p == n) return 0;
if (M[p] != -1) return M[p];
return M[p] = oink(W[p]) + 1;
}
ll oinkoinkoink(int p, ll z) {
if (p == n) return -1;
if (M2[p] != -1) return -1;
if (M3[p] != -1) {
return M2[p] = z - M3[p];
}
M3[p] = z;
ll a = oinkoinkoink(L[p], z + P[p]);
if (a == -1) return -1;
if (M2[p] != -1) return -1;
M2[p] = a;
return a;
}
void init(int N, std::vector<int> s, std::vector<int> p, std::vector<int> w, std::vector<int> l) {
n = N;
S = s;
P = p;
W = w;
L = l;
M = vi(n, -1);
M2 = vi(n, -1);
M3 = vi(n, -1);
for (int i = 0; i < n; i++) oinkoink(i);
for (int i = 0; i < n; i++) oinkoinkoink(i, 0);
return;
}
ll oink(int x, int z) {
if (z >= S[0]) return M[x]*S[0];
if (M2[x] == -1) return oink(L[x], z+P[x]);
z += ((S[0]-z-1)/M[x])*M[x];
return oink(L[x], z + P[x]);
}
long long simulate(int x, int z) {
while (x != n) {
if (S[x] <= z) {
z += S[x];
x = W[x];
continue;
}
z += P[x];
x = L[x];
}
return z;
}
Compilation message (stderr)
dungeons.cpp: In function 'long long int oinkoink(int)': dungeons.cpp:18:23: error: 'oink' was not declared in this scope 18 | return M[p] = oink(W[p]) + 1; | ^~~~ dungeons.cpp: In function 'void init(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)': dungeons.cpp:37:13: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>') 37 | S = s; | ^ In file included from /usr/include/c++/11/vector:72, from dungeons.h:1, from dungeons.cpp:1: /usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: '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>]' 198 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/vector.tcc:199:42: note: no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&' 199 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/11/vector:67, from dungeons.h:1, from dungeons.cpp:1: /usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:709:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 730 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:730:46: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>' 730 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ dungeons.cpp:38:13: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>') 38 | P = p; | ^ In file included from /usr/include/c++/11/vector:72, from dungeons.h:1, from dungeons.cpp:1: /usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: '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>]' 198 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/vector.tcc:199:42: note: no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&' 199 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/11/vector:67, from dungeons.h:1, from dungeons.cpp:1: /usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:709:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 730 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:730:46: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>' 730 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ dungeons.cpp:39:13: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>') 39 | W = w; | ^ In file included from /usr/include/c++/11/vector:72, from dungeons.h:1, from dungeons.cpp:1: /usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: '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>]' 198 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/vector.tcc:199:42: note: no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&' 199 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/11/vector:67, from dungeons.h:1, from dungeons.cpp:1: /usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:709:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 730 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:730:46: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>' 730 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ dungeons.cpp:40:13: error: no match for 'operator=' (operand types are 'std::vector<long long int>' and 'std::vector<int>') 40 | L = l; | ^ In file included from /usr/include/c++/11/vector:72, from dungeons.h:1, from dungeons.cpp:1: /usr/include/c++/11/bits/vector.tcc:198:5: note: candidate: '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>]' 198 | vector<_Tp, _Alloc>:: | ^~~~~~~~~~~~~~~~~~~ /usr/include/c++/11/bits/vector.tcc:199:42: note: no known conversion for argument 1 from 'std::vector<int>' to 'const std::vector<long long int>&' 199 | operator=(const vector<_Tp, _Alloc>& __x) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from /usr/include/c++/11/vector:67, from dungeons.h:1, from dungeons.cpp:1: /usr/include/c++/11/bits/stl_vector.h:709:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::vector<_Tp, _Alloc>&&) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:709:26: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::vector<long long int>&&' 709 | operator=(vector&& __x) noexcept(_Alloc_traits::_S_nothrow_move()) | ~~~~~~~~~^~~ /usr/include/c++/11/bits/stl_vector.h:730:7: note: candidate: 'std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(std::initializer_list<_Tp>) [with _Tp = long long int; _Alloc = std::allocator<long long int>]' 730 | operator=(initializer_list<value_type> __l) | ^~~~~~~~ /usr/include/c++/11/bits/stl_vector.h:730:46: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::initializer_list<long long int>' 730 | operator=(initializer_list<value_type> __l) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~