제출 #1021857

#제출 시각아이디문제언어결과실행 시간메모리
1021857m5588ohammedValley (BOI19_valley)C++14
0 / 100
128 ms12016 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" int n,S,E,q,U,V,x,l,mn,flag; vector <array<int,2>> v[100001],edges; priority_queue <array<int,2>> qu; int shops[100001]; void dfs(int i,int last,int sum){ if(i==E){ flag=1; return; } if(shops[i]==1) mn=min(mn,sum); for(auto [j,c]:v[i]){ if((i==U&&j==V)||(i==V&&j==U)||j==last) continue;; dfs(j,i,sum+c); } return; } void calc1(){ while(q--){ flag=0; mn=1e14; cin>>l>>x; U=edges[l-1][0]; V=edges[l-1][1]; dfs(x,0,0); if(flag==1) cout<<"escaped"<<endl; else if(mn!=1e14) cout<<mn<<endl; else cout<<"oo"<<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++){ int a; cin>>a; shops[a]=1; } if(n<=1000&&q<=1000) calc1(); return 0; }

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

valley.cpp: In function 'void dfs(long long int, long long int, long long int)':
valley.cpp:15:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   15 |     for(auto [j,c]: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...