Submission #361703

#TimeUsernameProblemLanguageResultExecution timeMemory
361703cuongdh1912Highway Tolls (IOI18_highway)C++14
0 / 100
49 ms1464 KiB
// moreflags=grader.cpp // :( #include "highway.h" #if not LOCAL #define NDEBUG #endif #include<cassert> #include<vector> #include<cstdint> #include<algorithm> #include <array> #include <queue> using namespace std; void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { int M = (int)U.size(); vector<int> w; w.resize(M, 0); const auto d = ask(w); int i = 0; // find the maximum of index where there is no shortest path has edge in 0..<i // therefore there must be an edge index i the shortest path have for (auto step = 1<<20; step>>=1;) { if (i + step < M) { w.assign(i+step, 1); w.resize(M, 0); if (d == ask(w)) { i += step; } } } struct Edge { int node, index;}; vector<vector<Edge> > add(N); for (int j = 0; j < M; ++j) { int a = U[j]; int b = V[j]; add[a].push_back({b, j}); add[b].push_back({a, j}); } array<vector<Edge>, 2> edges; edges[0].push_back({U[i], i}); edges[1].push_back({V[i], i}); vector<bool> visited(M, false); for (int j = 0; j < edges.size(); ++j) { // find maximum queue<int> q; q.push(edges[j][0].node); visited[edges[j][0].node] = true; while (q.size() > 0) { int v = q.front(); q.pop(); for (auto e: add[v]) { if (!visited[e.node]) { visited[e.node] = true; q.push(e.node); edges[j].push_back(e); } } } } int ans[2]; for (int j = 0; j < edges.size(); ++j ) { int k = (int)edges[j].size(); for (int step = 1<<20; step>>=1; ) { if (k - step > 0) { w.assign(M, 1); w[i] = 0; for (int l = 0; l < k - step; ++l) w[edges[j][l].index] = 0; for (int l = 0; l < edges[!j].size(); ++l ) w[edges[!j][l].index] = 0; if (d == ask(w)) { k -= step; } } } ans[j] = edges[j][k-1].node; } answer(ans[0], ans[1]); }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:46:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::array<std::vector<find_pair(int, std::vector<int>, std::vector<int>, int, int)::Edge>, 2>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     for (int j = 0; j < edges.size(); ++j) {
      |                     ~~^~~~~~~~~~~~~~
highway.cpp:65:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::array<std::vector<find_pair(int, std::vector<int>, std::vector<int>, int, int)::Edge>, 2>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |     for (int j = 0; j < edges.size(); ++j ) {
      |                     ~~^~~~~~~~~~~~~~
highway.cpp:72:35: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<find_pair(int, std::vector<int>, std::vector<int>, int, int)::Edge>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |                 for (int l = 0; l < edges[!j].size(); ++l ) w[edges[!j][l].index] = 0;
      |                                 ~~^~~~~~~~~~~~~~~~~~
#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...