제출 #1314130

#제출 시각아이디문제언어결과실행 시간메모리
1314130mikolaj00Minerals (JOI19_minerals)C++20
컴파일 에러
0 ms0 KiB
#include <cstdio> #include <cstdlib> #include <vector> #include "minerals.h" using namespace std; #define DEBUG false; vector<bool> in; int cnt = 0; bool call_query(int k) { in[k] = !in[k]; int old_cnt = cnt; cnt = Query(k); if (old_cnt != cnt) return true; else return false; } void Solve(int N) { in = vector<bool>(2*N+1); vector<pair<vector<int>, vector<int>>> nodes(1); for (int i = 1; i <= 2*N; i++) { if (call_query(i)) nodes[0].second.push_back(i); else { nodes[0].first.push_back(i); } } vector<int> cur_first; vector<pair<int, int>> ans; while (!nodes.empty()) { vector<pair<vector<int>, vector<int>>> new_nodes; for (auto[a, b] : nodes) { if (a.size() == 1) continue; int mid = a.size()/2; for (int i = 0; i < mid; i++) if (!in[a[i]]) call_query(a[i]); for (int i = mid; i < a.size(); i++) if (in[a[i]]) call_query(a[i]); } for (auto[a, b] : nodes) { if (a.size() == 1) { ans.push_back({a[0], b[0]}); continue; } vector<int> a1, b1, a2, b2; int mid = a.size()/2; for (int i = 0; i < mid; i++) a1.push_back(a[i]); for (int i = mid; i < a.size(); i++) a2.push_back(a[i]); for (int i = 0; i < b.size(); i++) { if (!call_query(b[i])) b1.push_back(b[i]); else b2.push_back(b[i]); } new_nodes.push_back({a1, b1}); new_nodes.push_back({a2, b2}); } nodes = new_nodes; } for (auto[a, b] : ans) Answer(a, b); } constexpr int MAX_N = 43000; constexpr int MAX_CALLS = 1000000; #if DEBUG namespace { void WrongAnswer(int code) { printf("Wrong Answer [%d]\n", code); exit(0); } int N; int counterpart[2 * MAX_N + 1]; int num_queries; int num_kinds; int on[2 * MAX_N + 1]; int count[2 * MAX_N + 1]; int num_answers; int answer[2 * MAX_N + 1]; } // namespace int Query(int x) { if (!(1 <= x && x <= 2 * N)) { WrongAnswer(1); } if (++num_queries > MAX_CALLS) { WrongAnswer(2); } const int type = std::min(x, counterpart[x]); if (on[x]) { --on[x]; --count[type]; if (count[type] == 0) { --num_kinds; } } else { ++on[x]; ++count[type]; if (count[type] == 1) { ++num_kinds; } } return num_kinds; } void Answer(int a, int b) { if (++num_answers > N) { WrongAnswer(6); } if (!(1 <= a && a <= 2 * N && 1 <= b && b <= 2 * N)) { WrongAnswer(3); } if (answer[a] != 0) { WrongAnswer(4); } answer[a] = b; if (answer[b] != 0) { WrongAnswer(4); } answer[b] = a; if (!(counterpart[a] == b && counterpart[b] == a)) { WrongAnswer(5); } } int main() { if (scanf("%d", &N) != 1) { fprintf(stderr, "Error while reading input\n"); exit(1); } for (int i = 1; i <= N; ++i) { int x, y; if (scanf("%d%d", &x, &y) != 2) { fprintf(stderr, "Error while reading input\n"); exit(1); } counterpart[x] = y; counterpart[y] = x; } Solve(N); if (num_answers != N) { WrongAnswer(6); } printf("Accepted: %d\n", num_queries); return 0; } #endif

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

minerals.cpp:7:20: error: token ";" is not valid in preprocessor expressions
    7 | #define DEBUG false;
      |                    ^
minerals.cpp:92:5: note: in expansion of macro 'DEBUG'
   92 | #if DEBUG
      |     ^~~~~