Submission #856809

#TimeUsernameProblemLanguageResultExecution timeMemory
856809Trisanu_DasValley (BOI19_valley)C++17
Compilation error
0 ms0 KiB
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> using namespace std; #define pb push_back #define int long long #define ff first #define ss second #define pi pair <int, int> int n, s, q, e; vector<int> d; int f[100001], l[100001]; pi road[100001]; int dt[1001]; bitset<100001> sh; vector <pi> g[100001]; void dfs(int p, int cur){ d.pb(cur); for(pi i: g[cur]) if(i.x!=p) dfs(cur, i.ff); d.pb(cur); } void bfs(int rip1, int rip2, int p, int cur){ for(pi i: g[cur]){ if(i.x!=p && (min(cur, i.x)!=rip1 || max(cur, i.x)!=rip2)){ dt[i.x]=dt[cur]+i.y; bfs(rip1, rip2, cur, i.x); } } } int32_t main(){ ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cin>>n>>s>>q>>e; for(int i=1; i<=n-1; i++){ int x, y, z; cin>>x>>y>>z; road[i]={x, y}; g[x].pb({y, z}); g[y].pb({x, z}); } for(int i=1; i<=s; i++){ int x; cin>>x; sh[x]=1; } dfs(0, e); for(int i=0; i<d.size(); i++){ l[d[i]]=i+1; if(!f[d[i]]) f[d[i]]=i+1; } if(s==n){ for(int i=1; i<=q; i++){ int rd, r; cin>>rd>>r; int x=road[rd].x, y=road[rd].y; if(f[x]<=f[r] && l[x]>=l[r] && f[y]<=f[r] && l[y]>=l[r]) cout<<0<<"\n"; else cout<<"escaped\n"; } return 0; } for(int i=1; i<=q; i++){ int rd, r; cin>>rd>>r; int x=road[rd].x, y=road[rd].y; if(x>y) swap(x, y); if(f[x]<=f[r] && l[x]>=l[r] && f[y]<=f[r] && l[y]>=l[r]){ for(int j=1; j<=n; j++) dt[j]=1e18; dt[r]=0; bfs(x, y, 0, r); int ans=1e18; for(int i=1; i<=n; i++){ if(sh[i]) ans=min(ans, dt[i]); } if(ans!=1e18) cout<<ans<<"\n"; else cout<<"oo\n"; } else cout<<"escaped\n"; } }

Compilation message (stderr)

valley.cpp: In function 'void dfs(long long int, long long int)':
valley.cpp:20:28: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
   20 |     for(pi i: g[cur]) if(i.x!=p) dfs(cur, i.ff);
      |                            ^
valley.cpp: In function 'void bfs(long long int, long long int, long long int, long long int)':
valley.cpp:26:14: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
   26 |         if(i.x!=p && (min(cur, i.x)!=rip1 || max(cur, i.x)!=rip2)){
      |              ^
valley.cpp:26:34: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
   26 |         if(i.x!=p && (min(cur, i.x)!=rip1 || max(cur, i.x)!=rip2)){
      |                                  ^
valley.cpp:26:57: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
   26 |         if(i.x!=p && (min(cur, i.x)!=rip1 || max(cur, i.x)!=rip2)){
      |                                                         ^
valley.cpp:27:18: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
   27 |             dt[i.x]=dt[cur]+i.y;
      |                  ^
valley.cpp:27:31: error: 'struct std::pair<long long int, long long int>' has no member named 'y'
   27 |             dt[i.x]=dt[cur]+i.y;
      |                               ^
valley.cpp:28:36: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
   28 |             bfs(rip1, rip2, cur, i.x);
      |                                    ^
valley.cpp: In function 'int32_t main()':
valley.cpp:49:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     for(int i=0; i<d.size(); i++){
      |                  ~^~~~~~~~~
valley.cpp:57:28: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
   57 |             int x=road[rd].x, y=road[rd].y;
      |                            ^
valley.cpp:58:46: error: 'y' was not declared in this scope
   58 |             if(f[x]<=f[r] && l[x]>=l[r] && f[y]<=f[r] && l[y]>=l[r]) cout<<0<<"\n";
      |                                              ^
valley.cpp:66:24: error: 'struct std::pair<long long int, long long int>' has no member named 'x'
   66 |         int x=road[rd].x, y=road[rd].y;
      |                        ^
valley.cpp:67:14: error: 'y' was not declared in this scope
   67 |         if(x>y) swap(x, y);
      |              ^
valley.cpp:68:42: error: 'y' was not declared in this scope
   68 |         if(f[x]<=f[r] && l[x]>=l[r] && f[y]<=f[r] && l[y]>=l[r]){
      |                                          ^