Submission #463670

#TimeUsernameProblemLanguageResultExecution timeMemory
463670tomsydHighway Tolls (IOI18_highway)C++17
0 / 100
279 ms262148 KiB
#include "highway.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; vector<int> nodes; void dfs(int node, int prev){ for (int i:adj[node]){ if (i != prev){ dfs(i,node); } } nodes.emplace_back(node); } void find_pair(int N, vector<int> U, vector<int> V, int A, int B) { int M = U.size(); nodes.clear(); adj = vector<vector<int>>(N); for (int i=0; i<M; ++i){ adj[U[i]].emplace_back(V[i]); adj[V[i]].emplace_back(U[i]); } dfs(0,-1); vector<int> query; for (int i=0; i<N; ++i) query.emplace_back(1); int init = ask(query), crt = nodes[nodes.size()-1]; for (int j=0; j<nodes.size()-1; ++j){ query[nodes[j]] = 0; if (ask(query) != init){ crt = nodes[j]; break; } query[nodes[j]] = 1; } cout << crt; }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:29:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for (int j=0; j<nodes.size()-1; ++j){
      |                ~^~~~~~~~~~~~~~~
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...