제출 #319536

#제출 시각아이디문제언어결과실행 시간메모리
319536TeaTimeJakarta Skyscrapers (APIO15_skyscraper)C++17
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <set> #include <map> #include <queue> #include <random> #include <chrono> #include <tuple> #include <random> #include <cmath> #include <unordered_set> using namespace std; typedef long long ll; typedef long double ld; #define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); const ll SZ = 30002, INF = 1e9 + 10; ll n, m; unordered_set<ll> us; ll dist[SZ]; bool used[SZ]; vector<ll> cur[SZ]; int main() { fastInp; cin >> n >> m; ll ind = 0, ind2 = 0, b2 = 0; for (int i = 0; i < m; i++) { ll b, p; cin >> b >> p; cur[b].push_back(p); if (i == 0) { ind2 = b; b2 = p; } if (i == 1) { ind = b; } } queue<pair<ll, ll>> q; queue<ll> q2; q.push({ ind2, b2 }); for (int i = 0; i < n; i++) dist[i] = INF; dist[ind2] = 0; q2.push(0); swap(n, m); while (!q.empty()) { ll v = q.front().first; pair<ll, ll> u = q.front(); ll d = q2.front(); q2.pop(); q.pop(); ll c = u.second; if (us.find((v - c) + c * (m + 1)) == us.end()) { if (v - c >= 0 && v - c < m) { us.insert({ v - c, c }); dist[v - c] = min(dist[v - c], d + 1); q.push((v - c) + c * (m + 1)); q2.push({ d + 1 }); } } if (us.find((v + c) + c * (m + 1)) == us.end()) { if (v + c >= 0 && v + c < m) { us.insert((v + c) + c * (m + 1)); dist[v + c] = min(dist[v + c], d + 1); q.push({ v + c, c }); q2.push({ d + 1 }); } } if (!used[v]) { used[v] = 1; for (auto c : cur[v]) { if (us.find((v - c) + c * (m + 1)) == us.end()) { if (v - c >= 0 && v - c < m) { us.insert((v - c) + c * (m + 1)); dist[v - c] = min(dist[v - c], d + 1); q.push({ v - c, c }); q2.push({ d + 1 }); } } if (us.find((v + c) + c * (m + 1)) == us.end()) { if (v + c >= 0 && v + c < m) { us.insert((v + c) + c * (m + 1)); dist[v + c] = min(dist[v + c], d + 1); q.push({ v + c, c }); q2.push({ d + 1 }); } } } } if (dist[ind] != INF) { cout << dist[ind]; return 0; } } cout << "-1"; return 0; } /* 5 1 4 1 3 5 2 1 4 1 2 5 1 1 4 5 3 5 1 1 2 4 3 5 1 1 3 1 1 1 2 2 2 3 3 3 */

컴파일 시 표준 에러 (stderr) 메시지

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:71:33: error: no matching function for call to 'std::queue<std::pair<long long int, long long int> >::push(ll)'
   71 |     q.push((v - c) + c * (m + 1));
      |                                 ^
In file included from /usr/include/c++/9/queue:64,
                 from skyscraper.cpp:7:
/usr/include/c++/9/bits/stl_queue.h:259:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(const value_type&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<long long int, long long int>]'
  259 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/9/bits/stl_queue.h:259:30: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'const value_type&' {aka 'const std::pair<long long int, long long int>&'}
  259 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/9/bits/stl_queue.h:264:7: note: candidate: 'void std::queue<_Tp, _Sequence>::push(std::queue<_Tp, _Sequence>::value_type&&) [with _Tp = std::pair<long long int, long long int>; _Sequence = std::deque<std::pair<long long int, long long int>, std::allocator<std::pair<long long int, long long int> > >; std::queue<_Tp, _Sequence>::value_type = std::pair<long long int, long long int>]'
  264 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/9/bits/stl_queue.h:264:25: note:   no known conversion for argument 1 from 'll' {aka 'long long int'} to 'std::queue<std::pair<long long int, long long int> >::value_type&&' {aka 'std::pair<long long int, long long int>&&'}
  264 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~