# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
108885 | kuroni | Jakarta Skyscrapers (APIO15_skyscraper) | C++17 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
skyscraper
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#define fi first
#define se second
using namespace std;
const int N = 30005, D = 180, MX = 5E5 + 5, INF = 1E9 + 7;
int n, m, d, b, p, st, en, dis[N][D];
vector<int> dif[N];
vector<pair<int, int>> ve[MX];
void mini(pair<int, int> u, int v)
{
if (dis[u.fi][u.se] > v)
{
dis[u.fi][u.se] = v;
ve[v].push_back(u);
}
}
void dijkstra()
{
for (int i = 0; i < n; i++)
for (int j = 0; j < d; j++)
dis[i][j] = INF;
dis[st][0] = 0; ve[0].push_back({st, 0});
for (int i = 0; i < MX; i++)
while (!ve[i].empty())
{
pair<int, int> u = ve[i].back(); ve[i].pop_back();
if (u.se == 0)
{
for (int &v : dif[u.fi])
{
if (v < d)
mini({u.fi, v}, i);
else
for (int j = u.fi % v; j < n; j += v)
mini({j, 0}, i + abs(u.fi - j) / v);
}
}
else
{
mini({u.fi, 0}, i);
if (u.fi + u.se < n)
mini({u.fi + u.se, u.se}, i + 1);
if (u.fi - u.se >= 0)
mini({u.fi - u.se, u.se}, i + 1);
}
}
printf("%d\n", dis[en][0] == INF ? -1 : dis[en][0]);
}
int main()
{
scanf("%d%d", &n, &m);
d = sqrt(n - 1) + 1;
for (int i = 0; i < m; i++)
{
scanf("%d%d", &b, &p);
if (i == 0)
st = b;
else if (i == 1)
en = b;
dif[b].push_back(p);
}
for (int i = 0; i < n; i++)
{
sort(dif[i].begin(), dif[i].end());
dif[i].erase(unique(dif[i].begin(), dif[i].end()), dif[i].end());
}
dijkstra();
}
Compilation message (stderr)
skyscraper.cpp:2:5: error: 'skyscraper' does not name a type skyscraper ^~~~~~~~~~ In file included from /usr/include/c++/7/iosfwd:40:0, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/bits/postypes.h:98:11: error: 'ptrdiff_t' does not name a type typedef ptrdiff_t streamsize; // Signed integral type ^~~~~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:120:31: error: declaration of 'operator new' as non-function void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) ^ /usr/include/c++/7/new:120:25: error: 'size_t' is not a member of 'std' void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) ^~~~~~ /usr/include/c++/7/new:120:25: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:122:33: error: declaration of 'operator new []' as non-function void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) ^ /usr/include/c++/7/new:122:27: error: 'size_t' is not a member of 'std' void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc) ^~~~~~ /usr/include/c++/7/new:122:27: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:129:29: error: 'std::size_t' has not been declared void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT ^~~ /usr/include/c++/7/new:131:31: error: 'std::size_t' has not been declared void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT ^~~ /usr/include/c++/7/new:134:25: error: declaration of 'operator new' as non-function void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^~~~~~ /usr/include/c++/7/new:134:25: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:134:25: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:134:33: error: expected primary-expression before 'const' void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^~~~~ /usr/include/c++/7/new:136:27: error: declaration of 'operator new []' as non-function void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^~~~~~ /usr/include/c++/7/new:136:27: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:136:27: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:136:35: error: expected primary-expression before 'const' void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT ^~~~~ /usr/include/c++/7/new:143:25: error: declaration of 'operator new' as non-function void* operator new(std::size_t, std::align_val_t) ^~~~~~ /usr/include/c++/7/new:143:25: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:143:25: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:143:49: error: expected primary-expression before ')' token void* operator new(std::size_t, std::align_val_t) ^ /usr/include/c++/7/new:145:25: error: declaration of 'operator new' as non-function void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) ^~~~~~ /usr/include/c++/7/new:145:25: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:145:25: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:145:49: error: expected primary-expression before ',' token void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) ^ /usr/include/c++/7/new:145:51: error: expected primary-expression before 'const' void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&) ^~~~~ /usr/include/c++/7/new:151:27: error: declaration of 'operator new []' as non-function void* operator new[](std::size_t, std::align_val_t) ^~~~~~ /usr/include/c++/7/new:151:27: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:151:27: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:151:51: error: expected primary-expression before ')' token void* operator new[](std::size_t, std::align_val_t) ^ /usr/include/c++/7/new:153:27: error: declaration of 'operator new []' as non-function void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) ^~~~~~ /usr/include/c++/7/new:153:27: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:153:27: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:153:51: error: expected primary-expression before ',' token void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) ^ /usr/include/c++/7/new:153:53: error: expected primary-expression before 'const' void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&) ^~~~~ /usr/include/c++/7/new:160:29: error: 'std::size_t' has not been declared void operator delete(void*, std::size_t, std::align_val_t) ^~~ /usr/include/c++/7/new:162:31: error: 'std::size_t' has not been declared void operator delete[](void*, std::size_t, std::align_val_t) ^~~ /usr/include/c++/7/new:168:32: error: declaration of 'operator new' as non-function inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT ^~~~~~ /usr/include/c++/7/new:168:32: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:168:32: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:168:40: error: expected primary-expression before 'void' inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT ^~~~ /usr/include/c++/7/new:170:34: error: declaration of 'operator new []' as non-function inline void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT ^~~~~~ /usr/include/c++/7/new:170:34: error: 'size_t' is not a member of 'std' /usr/include/c++/7/new:170:34: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/exception_ptr.h:40:0, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/new:170:42: error: expected primary-expression before 'void' inline void* operator new[](std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT ^~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/type_traits:362:26: error: 'std::size_t' has not been declared template<typename _Tp, std::size_t _Size> ^~~ /usr/include/c++/7/type_traits:363:25: error: '_Size' was not declared in this scope struct is_array<_Tp[_Size]> ^~~~~ /usr/include/c++/7/type_traits:363:31: error: template argument 1 is invalid struct is_array<_Tp[_Size]> ^ /usr/include/c++/7/type_traits:561:42: error: 'nullptr_t' is not a member of 'std' struct __is_null_pointer_helper<std::nullptr_t> ^~~~~~~~~ /usr/include/c++/7/type_traits:561:42: note: suggested alternative: In file included from /usr/include/c++/7/bits/cxxabi_init_exception.h:38:0, from /usr/include/c++/7/bits/exception_ptr.h:38, from /usr/include/c++/7/exception:142, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:444:29: note: 'nullptr_t' typedef decltype(nullptr) nullptr_t; ^~~~~~~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/type_traits:561:51: error: template argument 1 is invalid struct __is_null_pointer_helper<std::nullptr_t> ^ /usr/include/c++/7/type_traits:1464:37: error: 'size_t' is not a member of 'std' : public integral_constant<std::size_t, __alignof__(_Tp)> { }; ^~~~~~ /usr/include/c++/7/type_traits:1464:37: note: suggested alternative: In file included from /usr/include/wchar.h:51:0, from /usr/include/c++/7/cwchar:44, from /usr/include/c++/7/bits/postypes.h:40, from /usr/include/c++/7/iosfwd:40, from /usr/include/c++/7/ios:38, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/lib/gcc/x86_64-linux-gnu/7/include/stddef.h:216:23: note: 'size_t' typedef __SIZE_TYPE__ size_t; ^~~~~~ In file included from /usr/include/c++/7/bits/move.h:54:0, from /usr/include/c++/7/bits/nested_exception.h:40, from /usr/include/c++/7/exception:143, from /usr/include/c++/7/ios:39, from /usr/include/c++/7/ostream:38, from /usr/include/c++/7/iostream:39, from skyscraper.cpp:4: /usr/include/c++/7/type_traits:1464:61: error: template argument 1 is invalid : public integral_constant<std::size_t, __alignof__(_Tp)> { }; ^ /usr/include/c++/7/type_traits:1464:61: note: invalid template non-type parameter /usr/include/c++/7/type_traits:1469:37: error: 'size_t' is no