Submission #238134

#TimeUsernameProblemLanguageResultExecution timeMemory
238134HellAngelJakarta Skyscrapers (APIO15_skyscraper)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int maxn = 50007; int n, m, a[maxn], start[maxn], len[maxn], dist[maxn]; vector<int> pos[maxn]; priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> pq; bool Inside(int x) { return (x >= 0 && x < n); } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout); cin >> n >> m; fill_n(dist, n, 1e9); for(int i = 1; i <= m; i++) { cin >> start[i] >> len[i]; pos[start[i]].push_back(len[i]); } for(int i = 0; i < n; i++) { sort(pos[i].begin(), pos[i].end()); pos[i].erase(unique(pos[i].begin(), pos[i].end()), pos[i].end()); reverse(pos[i].begin(), pos[i],end()); } if(m == 1) { cout << -1; return 0; } dist[start[1]] = 0; pq.emplace(0, start[1]); while(pq.size()) { pair<int, int> p = pq.top(); pq.pop(); if(p.first != dist[p.second]) continue; int u = p.second; if(u == start[2]) { cout << p.first; exit(0); } for(auto j: pos[u]) { int cnt = 0; for(int i = 1;;i++) { int nxt = u + i * j; bool ok = 0; bool sure = 0; ok |= Inside(nxt); if(Inside(nxt) && dist[nxt] > dist[u] + i) { sure = 1; dist[nxt] = dist[u] + i; pq.emplace(dist[nxt], nxt); } nxt = u - i * j; ok |= Inside(nxt); if(Inside(nxt) && dist[nxt] > dist[u] + i) { sure = 1; dist[nxt] = dist[u] + i; pq.emplace(dist[nxt], nxt); } if(!sure) { cnt++; } else cnt = 0; if(cnt >= 10000) break; if(!ok) break; } } } cout << -1; }

Compilation message (stderr)

skyscraper.cpp: In function 'int32_t main()':
skyscraper.cpp:32:44: error: no matching function for call to 'end()'
         reverse(pos[i].begin(), pos[i],end());
                                            ^
In file included from /usr/include/c++/7/bits/range_access.h:36:0,
                 from /usr/include/c++/7/string:51,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from skyscraper.cpp:1:
/usr/include/c++/7/initializer_list:99:5: note: candidate: template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^~~
/usr/include/c++/7/initializer_list:99:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:32:44: note:   candidate expects 1 argument, 0 provided
         reverse(pos[i].begin(), pos[i],end());
                                            ^
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/range_access.h:68:5: note: candidate: template<class _Container> decltype (__cont.end()) std::end(_Container&)
     end(_Container& __cont) -> decltype(__cont.end())
     ^~~
/usr/include/c++/7/bits/range_access.h:68:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:32:44: note:   candidate expects 1 argument, 0 provided
         reverse(pos[i].begin(), pos[i],end());
                                            ^
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/range_access.h:78:5: note: candidate: template<class _Container> decltype (__cont.end()) std::end(const _Container&)
     end(const _Container& __cont) -> decltype(__cont.end())
     ^~~
/usr/include/c++/7/bits/range_access.h:78:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:32:44: note:   candidate expects 1 argument, 0 provided
         reverse(pos[i].begin(), pos[i],end());
                                            ^
In file included from /usr/include/c++/7/string:51:0,
                 from /usr/include/c++/7/bits/locale_classes.h:40,
                 from /usr/include/c++/7/bits/ios_base.h:41,
                 from /usr/include/c++/7/ios:42,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from skyscraper.cpp:1:
/usr/include/c++/7/bits/range_access.h:97:5: note: candidate: template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])
     end(_Tp (&__arr)[_Nm])
     ^~~
/usr/include/c++/7/bits/range_access.h:97:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:32:44: note:   candidate expects 1 argument, 0 provided
         reverse(pos[i].begin(), pos[i],end());
                                            ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from skyscraper.cpp:1:
/usr/include/c++/7/valarray:1221:5: note: candidate: template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)
     end(valarray<_Tp>& __va)
     ^~~
/usr/include/c++/7/valarray:1221:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:32:44: note:   candidate expects 1 argument, 0 provided
         reverse(pos[i].begin(), pos[i],end());
                                            ^
In file included from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:95:0,
                 from skyscraper.cpp:1:
/usr/include/c++/7/valarray:1231:5: note: candidate: template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)
     end(const valarray<_Tp>& __va)
     ^~~
/usr/include/c++/7/valarray:1231:5: note:   template argument deduction/substitution failed:
skyscraper.cpp:32:44: note:   candidate expects 1 argument, 0 provided
         reverse(pos[i].begin(), pos[i],end());
                                            ^
skyscraper.cpp:20:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     if(fopen("test.inp", "r")) freopen("test.inp", "r", stdin), freopen("test.out", "w", stdout);
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
skyscraper.cpp:20:63: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]