Submission #907245

#TimeUsernameProblemLanguageResultExecution timeMemory
907245yellowtoadJakarta Skyscrapers (APIO15_skyscraper)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <map> #include <vector> #include <queue> #define f first #define s second using namespace std; int n, m, cnt, st, ed, dist[10000010], vis[10000010]; map<pair<int,int>,int> mp; vector<vector<pair<int,int>>> edge[10000010]; deque<int> q; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; cnt = n-1; //for (int i = 0; i < n; i++) edge.push_back({}); for (int i = 1; i <= m; i++) { int u, v; cin >> u >> v; if (i == 1) st = u; if (i == 2) ed = u; if (!mp[{u,v}]) { for (int j = u%v; j < n; j += v) { mp[{j,v}] = ++cnt; edge[cnt].push_back({j,0}); if (j != u%v) { edge[cnt].push_back({cnt-1,1}); edge[cnt-1].push_back({cnt,1}); } } } edge[u].push_back({mp[{u,v}],0}); } for (int i = 0; i <= cnt; i++) dist[i] = 1e9; q.push_back(st); dist[st] = 0; while (q.size()) { int u = q.front(); q.pop_front(); if (vis[u]) continue; vis[u] = 1; if (u == ed) { cout << dist[ed] << endl; return 0; } for (int i = 0; i < edge[u].size(); i++) { if (dist[edge[u][i].f] > dist[u]+edge[u][i].s) { dist[edge[u][i].f] = dist[u]+edge[u][i].s; if (edge[u][i].s) q.push_back(edge[u][i].f); else q.push_front(edge[u][i].f); } } } cout << -1 << endl; }

Compilation message (stderr)

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:28:30: error: no matching function for call to 'std::vector<std::vector<std::pair<int, int> > >::push_back(<brace-enclosed initializer list>)'
   28 |     edge[cnt].push_back({j,0});
      |                              ^
In file included from /usr/include/c++/10/vector:67,
                 from skyscraper.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::vector<std::pair<int, int> >&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<std::pair<int, int> > >::value_type&&' {aka 'std::vector<std::pair<int, int> >&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
skyscraper.cpp:30:35: error: no matching function for call to 'std::vector<std::vector<std::pair<int, int> > >::push_back(<brace-enclosed initializer list>)'
   30 |      edge[cnt].push_back({cnt-1,1});
      |                                   ^
In file included from /usr/include/c++/10/vector:67,
                 from skyscraper.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::vector<std::pair<int, int> >&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<std::pair<int, int> > >::value_type&&' {aka 'std::vector<std::pair<int, int> >&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
skyscraper.cpp:31:35: error: no matching function for call to 'std::vector<std::vector<std::pair<int, int> > >::push_back(<brace-enclosed initializer list>)'
   31 |      edge[cnt-1].push_back({cnt,1});
      |                                   ^
In file included from /usr/include/c++/10/vector:67,
                 from skyscraper.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::vector<std::pair<int, int> >&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<std::pair<int, int> > >::value_type&&' {aka 'std::vector<std::pair<int, int> >&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
skyscraper.cpp:35:34: error: no matching function for call to 'std::vector<std::vector<std::pair<int, int> > >::push_back(<brace-enclosed initializer list>)'
   35 |   edge[u].push_back({mp[{u,v}],0});
      |                                  ^
In file included from /usr/include/c++/10/vector:67,
                 from skyscraper.cpp:3:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::vector<std::pair<int, int> >&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::vector<std::pair<int, int> >; _Alloc = std::allocator<std::vector<std::pair<int, int> > >; std::vector<_Tp, _Alloc>::value_type = std::vector<std::pair<int, int> >]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<std::pair<int, int> > >::value_type&&' {aka 'std::vector<std::pair<int, int> >&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
skyscraper.cpp:49:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |   for (int i = 0; i < edge[u].size(); i++) {
      |                   ~~^~~~~~~~~~~~~~~~
skyscraper.cpp:5:11: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<int, int> > >, std::vector<std::pair<int, int> > >::value_type' {aka 'class std::vector<std::pair<int, int> >'} has no member named 'first'
    5 | #define f first
      |           ^~~~~
skyscraper.cpp:50:24: note: in expansion of macro 'f'
   50 |    if (dist[edge[u][i].f] > dist[u]+edge[u][i].s) {
      |                        ^
skyscraper.cpp:6:11: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<int, int> > >, std::vector<std::pair<int, int> > >::value_type' {aka 'class std::vector<std::pair<int, int> >'} has no member named 'second'
    6 | #define s second
      |           ^~~~~~
skyscraper.cpp:50:48: note: in expansion of macro 's'
   50 |    if (dist[edge[u][i].f] > dist[u]+edge[u][i].s) {
      |                                                ^
skyscraper.cpp:5:11: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<int, int> > >, std::vector<std::pair<int, int> > >::value_type' {aka 'class std::vector<std::pair<int, int> >'} has no member named 'first'
    5 | #define f first
      |           ^~~~~
skyscraper.cpp:51:21: note: in expansion of macro 'f'
   51 |     dist[edge[u][i].f] = dist[u]+edge[u][i].s;
      |                     ^
skyscraper.cpp:6:11: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<int, int> > >, std::vector<std::pair<int, int> > >::value_type' {aka 'class std::vector<std::pair<int, int> >'} has no member named 'second'
    6 | #define s second
      |           ^~~~~~
skyscraper.cpp:51:45: note: in expansion of macro 's'
   51 |     dist[edge[u][i].f] = dist[u]+edge[u][i].s;
      |                                             ^
skyscraper.cpp:6:11: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<int, int> > >, std::vector<std::pair<int, int> > >::value_type' {aka 'class std::vector<std::pair<int, int> >'} has no member named 'second'
    6 | #define s second
      |           ^~~~~~
skyscraper.cpp:52:20: note: in expansion of macro 's'
   52 |     if (edge[u][i].s) q.push_back(edge[u][i].f);
      |                    ^
skyscraper.cpp:5:11: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<int, int> > >, std::vector<std::pair<int, int> > >::value_type' {aka 'class std::vector<std::pair<int, int> >'} has no member named 'first'
    5 | #define f first
      |           ^~~~~
skyscraper.cpp:52:46: note: in expansion of macro 'f'
   52 |     if (edge[u][i].s) q.push_back(edge[u][i].f);
      |                                              ^
skyscraper.cpp:5:11: error: '__gnu_cxx::__alloc_traits<std::allocator<std::vector<std::pair<int, int> > >, std::vector<std::pair<int, int> > >::value_type' {aka 'class std::vector<std::pair<int, int> >'} has no member named 'first'
    5 | #define f first
      |           ^~~~~
skyscraper.cpp:53:34: note: in expansion of macro 'f'
   53 |     else q.push_front(edge[u][i].f);
      |                                  ^