제출 #882764

#제출 시각아이디문제언어결과실행 시간메모리
882764Kel_MahmutJakarta Skyscrapers (APIO15_skyscraper)C++14
10 / 100
1 ms4444 KiB
#include <bits/stdc++.h> #define all(aa) aa.begin(), aa.end() #define pb push_back #define endl ("\n") typedef long long ll; using namespace std; const ll INF (1000000000000000); const int maxn = 2005, maxm = 2005; int n, m, target; bool vis[maxn][maxn]; vector<int> v[maxn]; ll d[maxn][maxn], sped; queue<array<ll, 3>> q; void pushq(ll u, ll s, ll dst){ if(u - s >= 0) q.push({u - s, s, dst}); if(u + s < n) q.push({u+s, s, dst}); } int main(){ cin >> n >> m; for(int i = 0; i < m; i++){ int b, p; cin >> b >> p; if(i == 0) sped = p; if(i != 1) v[b].pb(p); else target = b; } for(int i = 0; i < n; i++){ sort(all(v[i])); v[i].resize(unique(all(v[i])) - v[i].begin()); } for(int i = 0; i < n; i++){ for(int j = 1; j <= n; j++) d[i][j] = INF; } q.push({0, sped, 0}); while(!q.empty()){ auto [u, s, dst] = q.front(); q.pop(); if(vis[u][s]) { assert(d[u][s] <= dst); continue; } vis[u][s] = 1; d[u][s] = dst; for(int sp : v[u]) pushq(u, sp, dst+1); pushq(u, s, dst+1); } ll ans = INF; for(int i = 1; i <= n; i++){ ans = min(ans, d[target][i]); } if(ans == INF) cout << -1; else cout << ans; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:41:8: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   41 |   auto [u, s, dst] = q.front(); q.pop();
      |        ^
#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...