제출 #1021846

#제출 시각아이디문제언어결과실행 시간메모리
1021846m5588ohammedValley (BOI19_valley)C++14
0 / 100
87 ms11204 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" int n,S,E,q,U,V,x,l; vector <array<int,2>> v[100001],edges; priority_queue <array<int,2>> qu; int dis[100001],shops[100001]; void dij(){ for(int i=1;i<=n;i++) dis[i]=-1; dis[x]=0; qu.push({0,x}); while(!qu.empty()){ auto [mydis,i]=qu.top(); mydis*=-1; qu.pop(); if(mydis>dis[i]&&dis[i]!=-1) continue; for(auto [j,w]:v[i]){ if((i==U&&j==V)||(i==V&&j==U)) continue; if(dis[j]>mydis+w||dis[j]==-1){ dis[j]=mydis+w; qu.push({dis[j]*-1,j}); } } } return; } void calc1(){ while(q--){ cin>>l>>x; U=edges[l-1][0]; V=edges[l-1][1]; dij(); if(dis[E]!=-1){ cout<<"escaped"<<endl;continue;} int mn=1e14; for(int i=0;i<S;i++) if(dis[shops[i]]!=-1) mn=min(mn,dis[shops[i]]); if(mn==1e14) cout<<"oo"<<endl; else cout<<mn<<endl; } } signed main() { cin>>n>>S>>q>>E; for(int i=0;i<n-1;i++){ int a,b,c; cin>>a>>b>>c; v[a].push_back({b,c}); v[b].push_back({a,c}); edges.push_back({a,b}); } for(int i=0;i<S;i++) cin>>shops[i]; if(n<=1000&&q<=1000) calc1(); return 0; }

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

valley.cpp: In function 'void dij()':
valley.cpp:14:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   14 |         auto [mydis,i]=qu.top();
      |              ^
valley.cpp:18:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   18 |         for(auto [j,w]:v[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...