제출 #504045

#제출 시각아이디문제언어결과실행 시간메모리
504045FronPawJakarta Skyscrapers (APIO15_skyscraper)C++14
10 / 100
5 ms3520 KiB
#include <bits/stdc++.h> #define mod 1000000007 // https://www.youtube.com/watch?v=t5GDacP_2pQ using namespace std; ifstream in ("film.in"); ofstream out ("film.out"); int pow (int a, int b) { int rez = 1; while (b) { if (b&1) rez = (rez * a) % mod; a = (a * a) % mod; b>>=1; } return rez; } int n, m; int b[30001], p[30001]; vector <pair <int, int> > v[30001]; int ans[30001]; bool fr[30001][30001]; void dij (int start) { for (int i = 1;i<=30000;++i) ans[i] = 1<<30; ans[start] = 0; set <pair<int, int> > q; q.insert({0, start}); while (!q.empty()) { int nod = (*q.begin()).second; int cost = ans[nod]; for (auto vecin:v[nod]) if (cost + vecin.second < ans[vecin.first]) { if (ans[vecin.first] != 1<<30) q.erase(q.find({ans[vecin.first], vecin.first})); q.insert({cost + vecin.second, vecin.first}); ans[vecin.first] = cost + vecin.second; } q.erase(q.begin()); } } void solve () { cin >> n >> m; for (int i = 1; i<=m; ++i) cin >> b[i] >> p[i]; for (int i = 1; i<=m; ++i) { int place = b[i]; int cat = p[i]; place -= cat; int move1 = 1; while (place > 0) { if (fr[b[i]][place] == 0 || fr[b[i]][place] > move1); { v[b[i]].push_back({place, move1}); fr[b[i]][place] = move1; } move1++; place -= cat; } place = b[i] + cat; move1 = 1; while (place < n) { if (fr[b[i]][place] == 0 || fr[b[i]][place] > move1) { v[b[i]].push_back({place, move1}); fr[b[i]][place] = move1; } move1++; place += cat; } } dij(b[1]); if (ans[b[2]] == 1<<30) cout << -1 << ' '; else cout << ans[b[2]] << ' '; return; } main () { //ios_base::sync_with_stdio(false); //cin.tie(NULL); int t = 1; //cin >> t; while (t--) solve(); }

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

skyscraper.cpp: In function 'void solve()':
skyscraper.cpp:60:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   60 |             if (fr[b[i]][place] == 0 || fr[b[i]][place] > move1);
      |             ^~
skyscraper.cpp:61:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   61 |             {
      |             ^
skyscraper.cpp: At global scope:
skyscraper.cpp:88:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   88 | main ()
      | ^~~~
#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...