제출 #566171

#제출 시각아이디문제언어결과실행 시간메모리
566171hoanghq2004통행료 (IOI18_highway)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> //#include "highway.h" using namespace __gnu_pbds; using namespace std; template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; // //namespace { // //constexpr int MAX_NUM_CALLS = 100; //constexpr long long INF = 1LL << 61; // //int N, M, A, B, S, T; //std::vector<int> U, V; //std::vector<std::vector<std::pair<int, int>>> graph; // //bool answered, wrong_pair; //int num_calls; // //int read_int() { // int x; // if (scanf("%d", &x) != 1) { // fprintf(stderr, "Error while reading input\n"); // exit(1); // } // return x; //} // //void wrong_answer(const char *MSG) { // printf("Wrong Answer: %s\n", MSG); // exit(0); //} // //} // namespace // //long long ask(const std::vector<int> &w) { // if (++num_calls > MAX_NUM_CALLS) { // wrong_answer("more than 100 calls to ask"); // } // if (w.size() != (size_t)M) { // wrong_answer("w is invalid"); // } // for (size_t i = 0; i < w.size(); ++i) { // if (!(w[i] == 0 || w[i] == 1)) { // wrong_answer("w is invalid"); // } // } // // std::vector<bool> visited(N, false); // std::vector<long long> current_dist(N, INF); // std::queue<int> qa, qb; // qa.push(S); // current_dist[S] = 0; // while (!qa.empty() || !qb.empty()) { // int v; // if (qb.empty() || // (!qa.empty() && current_dist[qa.front()] <= current_dist[qb.front()])) { // v = qa.front(); // qa.pop(); // } else { // v = qb.front(); // qb.pop(); // } // if (visited[v]) { // continue; // } // visited[v] = true; // long long d = current_dist[v]; // if (v == T) { // return d; // } // for (auto e : graph[v]) { // int vv = e.first; // int ei = e.second; // if (!visited[vv]) { // if (w[ei] == 0) { // if (current_dist[vv] > d + A) { // current_dist[vv] = d + A; // qa.push(vv); // } // } else { // if (current_dist[vv] > d + B) { // current_dist[vv] = d + B; // qb.push(vv); // } // } // } // } // } // return -1; //} // //void answer(int s, int t) { // if (answered) { // wrong_answer("answered not exactly once"); // } // // if (!((s == S && t == T) || (s == T && t == S))) { // wrong_pair = true; // } // // answered = true; //} void find_pair(int n, vector<int> U, vector<int> V, int A, int B) { int m = U.size(); vector <int> w(m, 0); int cnt = ask(w) / A; int z = 0, x = 0, y = 0; for (int lg = 0; (1 << lg) < n; ++lg) { vector <int> w(m); for (int i = 0; i < m; ++i) if ((U[i] >> lg & 1) == (V[i] >> lg & 1)) w[i] = 1; else w[i] = 0; int _ = ask(w); if (_ % 2) z += (1 << lg); } // cout << z << '\n'; int split = __builtin_ctz(z); for (int lg = 0; (1 << lg) < n; ++lg) { if (lg == split) continue; vector <int> w(m); vector <int> gr(n); for (int i = 0; i < n; ++i) gr[i] = ((i >> split & 1) | (i >> lg & 1 ^ 1)); for (int i = 0; i < m; ++i) { if (gr[U[i]] == gr[V[i]]) w[i] = 1; else w[i] = 0; } int _ = ask(w); if (_ % 2) x += (1 << lg); } y = x ^ z; // cout << z << '\n'; answer(x, y); } /* 11 11 1 2 1 8 0 1 0 2 1 3 1 4 4 5 4 6 2 7 2 8 8 9 8 10 1 10 */ //int main() { // freopen("test.inp", "r", stdin); // N = read_int(); // M = read_int(); // A = read_int(); // B = read_int(); // S = read_int(); // T = read_int(); // cout << (S ^ T) << '\n'; // U.resize(M); // V.resize(M); // graph.assign(N, std::vector<std::pair<int, int>>()); // for (int i = 0; i < M; ++i) { // U[i] = read_int(); // V[i] = read_int(); // graph[U[i]].push_back({V[i], i}); // graph[V[i]].push_back({U[i], i}); // } // // answered = false; // wrong_pair = false; // num_calls = 0; // find_pair(N, U, V, A, B); // if (!answered) { // wrong_answer("answered not exactly once"); // } // if (wrong_pair) { // wrong_answer("{s, t} is wrong"); // } // printf("Accepted: %d\n", num_calls); // return 0; //}

컴파일 시 표준 에러 (stderr) 메시지

highway.cpp: In function 'void find_pair(int, std::vector<int>, std::vector<int>, int, int)':
highway.cpp:114:15: error: 'ask' was not declared in this scope
  114 |     int cnt = ask(w) / A;
      |               ^~~
highway.cpp:130:74: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
  130 |         for (int i = 0; i < n; ++i) gr[i] = ((i >> split & 1) | (i >> lg & 1 ^ 1));
      |                                                                  ~~~~~~~~^~~
highway.cpp:140:5: error: 'answer' was not declared in this scope
  140 |     answer(x, y);
      |     ^~~~~~
highway.cpp:114:9: warning: unused variable 'cnt' [-Wunused-variable]
  114 |     int cnt = ask(w) / A;
      |         ^~~