제출 #771287

#제출 시각아이디문제언어결과실행 시간메모리
771287IBoryJakarta Skyscrapers (APIO15_skyscraper)C++17
0 / 100
1 ms1108 KiB
#pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> #define pii pair<int, int> using namespace std; const int MAX = 30003; vector<pii> G[MAX]; int D[MAX]; int main() { ios::sync_with_stdio(0); cin.tie(0); int N, M; cin >> N >> M; map<pii, vector<int>> make; pii S, E; for (int i = 0; i < M; ++i) { int b, p; cin >> b >> p; if (i == 0) S = { b, p }; if (i == 1) E = { b, p }; make[{p, b % p}].push_back(b); } for (auto& [q, v] : make) { auto [p, init] = q; v.push_back(init); v.push_back(init + (N - 1 - init) / p * p); sort(v.begin(), v.end()); for (int i = 1; i + 1 < v.size(); ++i) { int n = v[i] - p, d = 1; while (n >= v[i - 1]) { G[v[i]].emplace_back(n, d++); n -= p; } n = v[i] + p, d = 1; while (n <= v[i + 1]) { G[v[i]].emplace_back(n, d++); n += p; } } } memset(D, 0x3f, sizeof(D)); D[0] = 0; priority_queue<pii, vector<pii>, greater<pii>> PQ; PQ.emplace(D[0] = 0, 0); while (!PQ.empty()) { auto [cd, cur] = PQ.top(); PQ.pop(); if (cd > D[cur]) continue; if (cur == 1) break; for (auto [next, nd] : G[cur]) { if (cd + nd >= D[next]) continue; PQ.emplace(D[next] = cd + nd, next); } } cout << (D[1] > 1E9 ? -1 : D[1]); return 0; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:32:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |   for (int i = 1; i + 1 < v.size(); ++i) {
      |                   ~~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...