제출 #905767

#제출 시각아이디문제언어결과실행 시간메모리
905767Sir_Ahmed_ImranJakarta Skyscrapers (APIO15_skyscraper)C++17
57 / 100
485 ms262144 KiB
///~~~LOTA~~~/// #include <bits/stdc++.h> using namespace std; #define nl '\n' #define ff first #define ss second #define ll long long #define append push_back #define pii pair<int,int> #define all(x) (x).begin(),(x).end() #define MAXN 30001 int x[MAXN]; int y[MAXN]; int dist[MAXN]; unordered_set<int> b[MAXN]; unordered_map<int,int> a[MAXN]; void solve(){ int n,m,o,p,q,r; cin>>n>>m; for(int i=0;i<m;i++){ cin>>x[i]>>y[i]; b[x[i]].insert(y[i]); } for(int i=0;i<n;i++){ dist[i]=INT_MAX; for(int j:b[i]){ for(int k=i%j;k<n;k+=j){ if(i==k) continue; if(a[i][k]==0) a[i][k]=abs(i-k)/j; a[i][k]=min(a[i][k],abs(i-k)/j); } } } dist[x[0]]=0; set<pii> s{{0,x[0]}}; while(!s.empty()){ p=(*s.begin()).ss; q=(*s.begin()).ff; s.erase(s.begin()); if(p==x[1]){ cout<<q; return; } if(q==dist[p]){ for(pii i:a[p]){ if(q+i.ss<dist[i.ff]){ dist[i.ff]=q+i.ss; s.insert({q+i.ss,i.ff}); } } } } cout<<-1; } int main(){ ios_base::sync_with_stdio(false);cin.tie(NULL); solve(); return 0; }

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

skyscraper.cpp: In function 'void solve()':
skyscraper.cpp:18:13: warning: unused variable 'o' [-Wunused-variable]
   18 |     int n,m,o,p,q,r;
      |             ^
skyscraper.cpp:18:19: warning: unused variable 'r' [-Wunused-variable]
   18 |     int n,m,o,p,q,r;
      |                   ^
#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...