Submission #282014

#TimeUsernameProblemLanguageResultExecution timeMemory
282014biggValley (BOI19_valley)C++14
23 / 100
182 ms14584 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll INF = 1e18; const int MAXN = 1e5 + 10; int n; vector<int >grafo[MAXN]; int tin[MAXN], tout[MAXN], altura[MAXN]; int T; void dfs(int x, int p){ tin[x] = ++T; for(int i = 0; i < grafo[x].size(); i++){ int viz = grafo[x][i];//, id = grafo[x][i].second.first; if(viz == p /*|| id == ip*/) continue; altura[viz] = altura[x] + 1; //dist[viz] = dist[x] + grafo[x][i].second.second; dfs(viz, x); } tout[x] =T; } int s, e, q; //std::vector<int> shops; pair<int, int> arestas[MAXN]; bool checkin(int id1, int id2){ if(tin[id1] <= tin[id2] && tout[id1] >= tin[id2] ) return true; return false; } int main(){ scanf("%d %d %d %d", &n, &s, &q, &e); for(int i = 1; i < n; i++){ int u, v; ll w; scanf("%d %d %lld", &u, &v, &w); grafo[u].push_back(v); grafo[v].push_back(u); arestas[i] = make_pair(u, v); } for(int i = 0; i < s; i++){ int k; scanf("%d", &k); } dfs(e, 0); for(int i = 1; i <= q; i++){ int id, k; scanf("%d %d", &id, &k); int u = arestas[id].first, v = arestas[id].second; if(altura[u] < altura[v]) swap(u, v); if(checkin(u, k)) printf("0\n"); else printf("escaped\n"); } }

Compilation message (stderr)

valley.cpp: In function 'void dfs(int, int)':
valley.cpp:12:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i = 0; i < grafo[x].size(); i++){
      |                 ~~^~~~~~~~~~~~~~~~~
valley.cpp: In function 'int main()':
valley.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   29 |  scanf("%d %d %d %d", &n, &s, &q, &e);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
valley.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |   scanf("%d %d %lld", &u, &v, &w);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
valley.cpp:41:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   41 |   scanf("%d", &k);
      |   ~~~~~^~~~~~~~~~
valley.cpp:48:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   48 |   scanf("%d %d", &id, &k);
      |   ~~~~~^~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...