제출 #768911

#제출 시각아이디문제언어결과실행 시간메모리
768911raysh07Jakarta Skyscrapers (APIO15_skyscraper)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define INF (int)1e18 #define f first #define s second mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count()); void Solve() { int n, m; cin >> n >> m; vector <pair<int, int>> a(m); set <int> st[n]; int target; vector <int> d(n, INF); priority_queue <pair<int, int>> pq; for (int i = 0; i < m; i++){ cin >> a[i].f >> a[i].s; if (i == 0) { d[a[i].f] = 0; pq.push({0, a[i].f}); } if (i != 1) st[a[i].f].insert(a[i].s); else target = a[i].f; } vector<vector<pair<int, int>>> adj(n); for (int i = 0; i < n; i++){ for (auto x : st[i]){ for (int j = 1; ; j++){ int go = x * j + i; if (go >= n || go < 0) break; adj[i].push_back({go, j}); if (st[go].find(x) != st.end()) break; } for (int j = 1; ; j++){ int go = i - x * j; if (go < 0 || go >= n) break; adj[i].push_back({go, j}); if (st[go].find(x) != st.end()) break; } } } while (!pq.empty()){ auto pi = pq.top(); pq.pop(); int u = pi.second; int ds = -pi.first; if (d[u] != ds) continue; for (auto [v, w] : adj[u]){ if (d[v] > d[u] + w){ d[v] = d[u] + w; pq.push({-d[v], v}); } } } // cout << target << "\n"; if (d[target] == INF) cout << -1 << "\n"; else cout << d[target] << "\n"; } int32_t main() { auto begin = std::chrono::high_resolution_clock::now(); ios_base::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; for(int i = 1; i <= t; i++) { //cout << "Case #" << i << ": "; Solve(); } auto end = std::chrono::high_resolution_clock::now(); auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin); cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; return 0; }

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

skyscraper.cpp: In function 'void Solve()':
skyscraper.cpp:37:42: error: request for member 'end' in 'st', which is of non-class type 'std::set<long long int> [n]'
   37 |                 if (st[go].find(x) != st.end()) break;
      |                                          ^~~
skyscraper.cpp:44:42: error: request for member 'end' in 'st', which is of non-class type 'std::set<long long int> [n]'
   44 |                 if (st[go].find(x) != st.end()) break;
      |                                          ^~~