제출 #604432

#제출 시각아이디문제언어결과실행 시간메모리
604432SeDunionICC (CEOI16_icc)C++17
컴파일 에러
0 ms0 KiB
#include<algorithm> #include<iostream> #include<vector> using namespace std; const int N = 103; int p[N]; int get(int x) { if (x == p[x]) return x; return p[x] = get(p[x]); } void run(int N) { for (int i = 1 ; i <= N ; ++ i) p[i] = i; for (int rep = 0 ; rep < N - 1 ; ++ rep) { vector<int>cur; for (int i = 1 ; i <= N ; ++ i) cur.emplace_back(get(i)); sort(cur.begin(), cur.end()); cur.resize(unique(cur.begin(), cur.end()) - cur.begin()); int m = cur.size(); int diff = 0; for (int b = 1 ; b <= m ; b <<= 1) { vector<int>A, B; for (int i = 0 ; i < m ; ++ i) { if (i >> b & 1) A.emplace_back(cur[i]); else B.emplace_back(cur[i]); } if (A.empty() || B.empty()) continue; int x = query(A.size(), B.size(), A, B); if (x) diff |= b; } vector<pair<int,int>>can; for (int i = 0 ; i < m ; ++ i) { int x = cur[i]; int y = (cur[i] ^ diff); if (1 <= y && y <= N) { can.emplace_back(x, y); } } int l = 0, r = (int)can.size() - 1; while (l < r) { int mid = (l + r) >> 1; vector<int>A, B; for (int i = 0 ; i <= mid ; ++ i) { A.emplace_back(can[i].first); B.emplace_back(can[i].second); } int x = query(A.size(), B.size(), A, B); if (x) r = mid; else l = mid + 1; } int x = can[r].first; int y = can[r].second; vector<int>X, Y; for (int i = 1 ; i <= N ; ++ i) { if (get(i) == x) X.emplace_back(i); if (get(i) == y) Y.emplace_back(i); } int lx = 0, rx = (int)X.size() - 1; while (lx < rx) { int mid = (lx + rx) >> 1; vector<int>A, B = Y; for (int i = 0 ; i <= mid ; ++ i) { A.emplace_back(X[i]); } int x = query(A.size(), B.size(), A, B); if (x) rx = mid; else lx = mid + 1; } int ly = 0, ry = (int)Y.size() - 1; while (ly < ry) { int mid = (ly + ry) >> 1; vector<int>A = X, B; for (int i = 0 ; i <= mid ; ++ i) { B.emplace_back(Y[i]); } int x = query(A.size(), B.size(), A, B); if (x) ry = mid; else ly = mid + 1; } int a = X[rx]; int b = Y[ry]; cout << "edge " << a << " " << b << endl; p[a] = b; setRoad(a, b); } }

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

icc.cpp: In function 'void run(int)':
icc.cpp:31:12: error: 'query' was not declared in this scope
   31 |    int x = query(A.size(), B.size(), A, B);
      |            ^~~~~
icc.cpp:50:12: error: 'query' was not declared in this scope
   50 |    int x = query(A.size(), B.size(), A, B);
      |            ^~~~~
icc.cpp:68:12: error: 'query' was not declared in this scope
   68 |    int x = query(A.size(), B.size(), A, B);
      |            ^~~~~
icc.cpp:79:12: error: 'query' was not declared in this scope
   79 |    int x = query(A.size(), B.size(), A, B);
      |            ^~~~~
icc.cpp:87:3: error: 'setRoad' was not declared in this scope
   87 |   setRoad(a, b);
      |   ^~~~~~~