제출 #108069

#제출 시각아이디문제언어결과실행 시간메모리
108069autumn_eelJakarta Skyscrapers (APIO15_skyscraper)C++14
0 / 100
20 ms19440 KiB
#include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) #define INF 0x3f3f3f3f using namespace std; typedef pair<int,int>P; typedef long long ll; int b[50000],t[50000]; int d[2200][2200]; vector<int>v[2200]; int main(){ int n,m;cin>>n>>m; rep(i,m){ scanf("%d%d",&b[i],&t[i]); v[b[i]].push_back(t[i]); } memset(d,0x3f,sizeof(d)); d[0][0]=0; deque<P>que; que.push_back(P(0,0)); while(!que.empty()){ P p=que.front();que.pop_front(); int c=d[p.first][p.second]; if(p.second==0){ for(int i:v[p.first]){ if(d[p.first][i]>c){ d[p.first][i]=c; que.push_front(P(p.first,i)); } } } else{ int v; if((v=p.first-p.second)>=0&&d[v][p.second]>c+1){ d[v][p.second]=c+1; que.push_back(P(v,p.second)); } if((v=p.first+p.second)<n&&d[v][p.second]>c+1){ d[v][p.second]=c+1; que.push_back(P(v,p.second)); } if(d[p.first][0]>c){ d[p.first][0]=c; que.push_front(P(p.first,0)); } } } int ans=*min_element(d[1],d[1]+2200); if(ans==INF)puts("-1"); else cout<<ans<<endl; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d",&b[i],&t[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...