제출 #1130041

#제출 시각아이디문제언어결과실행 시간메모리
1130041math_rabbit_1028스핑크스 (IOI24_sphinx)C++20
컴파일 에러
0 ms0 KiB
#include "sphinx.h" using namespace std; vector<int> adj[303]; vector<int> ch; void dfs(int v) { ch[v] = 1; for (int u : adj[v]) { if (ch[u]) continue; dfs(u); } } int other(int N, int v, int u) { int ret = 0; ch = vector<int>(N, 0); ch[v] = ch[u] = 1; for (int i = 0; i < N; i++) { if (ch[i]) continue; dfs(i); ret++; } return ret; } int trivial(vector<int> E) { int ret = 1; for (int i = 0; i < E.size(); i++) if (E[i] != N) E[i] = -1; for (int i = 1; i < E.size(); i++) if (E[i] != E[i-1]) ret++; return ret; } vector<int> vec; void solve(int s, int e, int x, int r, int c) { if (s == e) { vec.push_back(s); return; } int m = (s+e)/2; vector<int> E(N, N); for (int i = s; i <= m; i++) { if (i % 5 == r) { E[5*i+r] = -1; E[5*i+r+1] = c; } } int y = perform_experiment(E) - trivial(E); if (y > 0) solve(s, m, y, r, c); if (x-y > 0) solve(m+1, e, x-y, r, c); } vector<int> find_colours(int N, vector<int> X, vector<int> Y) { for (int i = 0; i < X.size(); i++) { adj[X[i]].push_back(Y[i]); adj[Y[i]].push_back(X[i]); } vector<int> color(N, 0); for (int i = 0; i < N; i++) color[i] = i; if (N <= 50) { for (int i = 0; i < N; i++) { vector<int> E(N, N); E[i] = -1; random_shuffle(color.begin(), color.end()); for (int j = 0; j < N; j++) { E[adj[i][0]] = color[j]; int x = perform_experiment(E); if (x - other(N, i, adj[i][0]) == 1) { C[i] = color[j]; break; } } } } else { for (int r = 0; r < 5; r++) { for (int j = 0; j < N; j++) { vector<int> E(N, N); int cnt = 0; for (int i = 0; i < N-1; i++) { if (i % 5 == r) { E[i] = -1; cnt++; } } for (int i = 1; i < N; i++) { if ((i - 1) % 5 == r) E[i] = color[j]; } int x = perform_experiment(E) - trivial(E); solve(0, cnt, x, r, color[j]); for (auto i : vec) C[i] = color[j]; } } vector<int> E(N, N); E[N-1] = -1; random_shuffle(color.begin(), color.end()); for (int j = 0; j < N; j++) { E[N-2] = color[j]; int x = perform_experiment(E); if (x == 2) { C[N-1] = color[j]; break; } } } return C; }

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

sphinx.cpp: In function 'int trivial(std::vector<int>)':
sphinx.cpp:27:52: error: 'N' was not declared in this scope
   27 |     for (int i = 0; i < E.size(); i++) if (E[i] != N) E[i] = -1;
      |                                                    ^
sphinx.cpp: In function 'void solve(int, int, int, int, int)':
sphinx.cpp:40:19: error: 'N' was not declared in this scope
   40 |     vector<int> E(N, N);
      |                   ^
sphinx.cpp: In function 'std::vector<int> find_colours(int, std::vector<int>, std::vector<int>)':
sphinx.cpp:70:21: error: 'C' was not declared in this scope
   70 |                     C[i] = color[j];
      |                     ^
sphinx.cpp:92:36: error: 'C' was not declared in this scope
   92 |                 for (auto i : vec) C[i] = color[j];
      |                                    ^
sphinx.cpp:103:17: error: 'C' was not declared in this scope
  103 |                 C[N-1] = color[j];
      |                 ^
sphinx.cpp:109:12: error: 'C' was not declared in this scope
  109 |     return C;
      |            ^