제출 #410200

#제출 시각아이디문제언어결과실행 시간메모리
410200jeqchoJakarta Skyscrapers (APIO15_skyscraper)C++17
57 / 100
776 ms262148 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pair<int,int>> vpi; #define FOR(i,a,b) for (int i = (a); i < (b); ++i) #define F0R(i,a) FOR(i,0,a) #define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i) #define R0F(i,a) ROF(i,0,a) #define trav(a,x) for (auto& a: x) #define pb push_back #define rsz resize #define sz(x) int(x.size()) #define all(x) begin(x), end(x) #define fi first #define se second int const N=3e4+3; int const sN=150; int d[N][sN]; int const INF=1e9; vector<pair<pii,int>>adj[N][sN]; bitset<sN> vis[N]; priority_queue<pair<int,pii>> q; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,m; cin>>n>>m; int b0,b1; F0R(i,m) { int bi,pi; cin>>bi>>pi; if(i==0)b0=bi; else if(i==1)b1=bi; if(pi>=sN) { int nxt=bi+pi; int cnt=1; while(nxt<n) { adj[bi][0].pb({{nxt,0},cnt}); ++cnt; nxt+=pi; } nxt=bi-pi; cnt=1; while(nxt>=0) { adj[bi][0].pb({{nxt,0},cnt}); ++cnt; nxt-=pi; } } else { adj[bi][0].pb({{bi,pi},0}); } } F0R(i,n) { fill(d[i],d[i]+sN,INF); } d[b0][0]=0; q.push({0,{b0,0}}); while(!q.empty()) { int pos = q.top().se.fi; int pw = q.top().se.se; q.pop(); if(vis[pos][pw])continue; vis[pos][pw]=1; if(pw!=0) { int nxt=pos+pw; if(nxt<n) { adj[pos][pw].pb({{nxt,pw},1}); adj[pos][pw].pb({{nxt,0},1}); } nxt=pos-pw; if(nxt>=0) { adj[pos][pw].pb({{nxt,pw},1}); adj[pos][pw].pb({{nxt,0},1}); } } trav(e,adj[pos][pw]) { int cand = d[pos][pw]+e.se; if(cand<d[e.fi.fi][e.fi.se]) { d[e.fi.fi][e.fi.se]=cand; q.push({-cand,e.fi}); } } adj[pos][pw].clear(); } if(d[b1][0]==INF)cout<<-1<<'\n'; else cout<<d[b1][0]<<'\n'; return 0; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:105:12: warning: 'b1' may be used uninitialized in this function [-Wmaybe-uninitialized]
  105 |  if(d[b1][0]==INF)cout<<-1<<'\n';
      |     ~~~~~~~^
#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...