제출 #953770

#제출 시각아이디문제언어결과실행 시간메모리
953770tnknguyen_Jakarta Skyscrapers (APIO15_skyscraper)C++14
10 / 100
2 ms6800 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define pii pair<int, int> const int MX = 3e5 + 5; int INF; int vi[MX], b[MX], p[MX]; int d[MX]; int n, m; // ------------ FUNCTIONS ----------- void bfs(){ memset(d, 63, sizeof d); INF = d[0]; priority_queue<pii> q; q.push({0, 1}); d[b[1]] = 0; int c = 0; while(q.size() && c <= 10){ ++c; int w, u; tie(w, u) = q.top(); w = -w; q.pop(); for(int i=1; i<=m; ++i){ int v = b[i]; int c = abs(b[u] - v) / p[u]; if(abs(b[u] - v) % p[u] == 0 && w + c < d[v]){ d[v] = w + c; q.push({-d[v], i}); } } } } // ------------ SUBTASKS ------------ namespace SUB123{ bool ok(){ return (n <= 2000 && m <= 2000); } void solve(){ bfs(); cout<<(d[b[2]] == INF ? -1 : d[b[2]]); //--------------------- exit(0); } } int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen("main.inp","r",stdin); //freopen("main.out","w",stdout); cin>>n>>m; for(int i=1; i<=m; ++i){ cin>>b[i]>>p[i]; } if(SUB123 :: ok){ SUB123 :: solve(); return 0; } return 0; }

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

skyscraper.cpp: In function 'int32_t main()':
skyscraper.cpp:69:18: warning: the address of 'bool SUB123::ok()' will never be NULL [-Waddress]
   69 |     if(SUB123 :: ok){
      |        ~~~~~~~~~~^~
#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...