Submission #423607

#TimeUsernameProblemLanguageResultExecution timeMemory
423607TangentHighway Tolls (IOI18_highway)C++17
12 / 100
181 ms9608 KiB
#include "highway.h" #include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef vector<int> vii; typedef vector<ll> vll; typedef vector<pii> vpii; typedef vector<pll> vpll; typedef vector<vii> vvii; typedef vector<vll> vvll; typedef vector<vpii> vvpii; typedef vector<vpll> vvpll; #define ffor(i, a, b) for (ll i = a; i < b; i++) #define rep(i, n) ffor(i, 0, n) #define forin(x, a) for (auto &x: a) #define all(a) a.begin(), a.end() void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) { int M = U.size(); vvpii adj(N); rep(i, M) { adj[U[i]].emplace_back(V[i], i); adj[V[i]].emplace_back(U[i], i); } vii depth(N, -1), pedge(N, -1); depth[0] = 0; function<void(int)> dfs; dfs = [&](int x) { forin(y, adj[x]) { if (depth[y.first] == -1) { depth[y.first] = depth[x] + 1; pedge[y.first] = y.second; dfs(y.first); } } }; dfs(0); ll tdepth = ask(vii(M)) / A; vii cand; rep(i, N) { if (depth[i] == tdepth) { cand.emplace_back(i); } } while (cand.size() > 1) { vii query(M); rep(i, cand.size() / 2) { query[pedge[cand[i]]] = 1; } if (ask(query) > tdepth * A) { cand.resize(cand.size() / 2); } else { ffor(i, cand.size() / 2, cand.size()) { cand[i - (cand.size() / 2)] = cand[i]; } cand.resize(cand.size() - (cand.size() / 2)); } } answer(0, cand[0]); }

Compilation message (stderr)

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:18:40: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 | #define ffor(i, a, b) for (ll i = a; i < b; i++)
      |                                        ^
highway.cpp:19:19: note: in expansion of macro 'ffor'
   19 | #define rep(i, n) ffor(i, 0, n)
      |                   ^~~~
highway.cpp:55:5: note: in expansion of macro 'rep'
   55 |     rep(i, cand.size() / 2) {
      |     ^~~
highway.cpp:18:40: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 | #define ffor(i, a, b) for (ll i = a; i < b; i++)
......
   61 |       ffor(i, cand.size() / 2, cand.size()) {
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
highway.cpp:61:7: note: in expansion of macro 'ffor'
   61 |       ffor(i, cand.size() / 2, cand.size()) {
      |       ^~~~
#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...