제출 #935365

#제출 시각아이디문제언어결과실행 시간메모리
935365tamir1Jakarta Skyscrapers (APIO15_skyscraper)C++14
22 / 100
459 ms262144 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second using namespace std; ll n,m,i,j,dist[30005],b[30005],p[30005],x,y; map<ll,ll> mp[30005]; map<ll,ll> ::iterator it; bitset<30005> vis; priority_queue<pair<ll,ll>> q; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; for(i=0;i<m;i++){ cin >> b[i] >> p[i]; if(i==1) continue; x=b[i]+p[i]; y=0; while(x<n){ y++; it=mp[b[i]].find(x); if(it==mp[b[i]].end()) mp[b[i]][x]=y; else mp[b[i]][x]=min(mp[b[i]][x],y); x+=p[i]; } x=b[i]-p[i]; y=0; while(x>=0){ y++; it=mp[b[i]].find(x); if(it==mp[b[i]].end()) mp[b[i]][x]=y; else mp[b[i]][x]=min(mp[b[i]][x],y); x-=p[i]; } } q.push({0,b[0]}); while(!q.empty()){ x=q.top().ss; y=q.top().ff; q.pop(); if(vis[x]) continue; dist[x]=-y; vis[x]=1; for(auto [p,r]:mp[x]){ if(!vis[p]){ q.push({y-r,p}); } } } if(vis[b[1]]) cout << dist[b[1]]; else cout << -1; }

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

skyscraper.cpp: In function 'int main()':
skyscraper.cpp:46:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   46 |   for(auto [p,r]:mp[x]){
      |            ^
#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...