제출 #1243296

#제출 시각아이디문제언어결과실행 시간메모리
1243296badge881죄수들의 도전 (IOI22_prison)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int MAXN = 5000; const int DEPTH = 8; int cnt[] = {2, 3, 3, 3, 3, 2, 2, 2}; int sz[] = {5000, 2499, 833, 277, 92, 30, 14, 6, 2}; int compute_val(int n, int level) { for (int i = 1; i <= level; i++) { if (n <= 1) return 1; n -= 2; n %= sz[i]; n++; } return n; } int main() { int _n; scanf("%d", &_n); vector<vector<int>> strategy; vector<int> base(MAXN + 1, 0); for (int i = 1; i <= MAXN; i++) { int val = compute_val(i, 0); if (val == 1) base[i] = -1; else if (val == sz[0]) base[i] = -2; else base[i] = (val - 2) / sz[1] + 1; } strategy.push_back(base); for (int d = 0; d < DEPTH; d++) { int turn = (d & 1) ^ 1; int ours = (turn == 0 ? -1 : -2); int theirs = -3 - ours; int offset = strategy.size() + cnt[d]; for (int j = 0; j < cnt[d]; j++) { vector<int> next(MAXN + 1); next[0] = turn; for (int i = 1; i <= MAXN; i++) { int val = compute_val(i, d); if (val == 1) next[i] = ours; else if (val == sz[d]) next[i] = theirs; else { int group = (val - 2) / sz[d + 1]; if (group < j) next[i] = ours; else if (group > j) next[i] = theirs; else { int val2 = compute_val(i, d + 1); if (val2 == 1) next[i] = ours; else if (val2 == sz[d + 1]) next[i] = theirs; else { if (d + 2 > DEPTH) { next[i] = -1; continue; } int next_group = (val2 - 2) / sz[d + 2]; next[i] = next_group + offset; } } } } strategy.push_back(next); } } for (int i = 0; i < strategy.size(); i++) { strategy[i].resize(_n + 1); for (int j = 0; j <= _n; j++) { strategy[i][j] = clamp(strategy[i][j], -2, (int)strategy.size() - 1); } } for (int A = 1; A <= _n; A++) { for (int B = 1; B <= _n; B++) { if (A == B) continue; bool decided = false; int state = 0; for (int step = 0; step < 500 && !decided; step++) { int who = strategy[state][0]; state = strategy[state][who == 0 ? A : B]; if (state < 0) { if ((state == -2 && B > A) || (state == -1 && B < A)) { printf("BAD: %d %d\n", A, B); return 0; } printf("%c\n", "BA"[state + 2]); decided = true; } } if (!decided) { printf("X\n"); return 0; } fflush(log_file); } } return 0; }

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

prison.cpp: In function 'int main()':
prison.cpp:135:20: error: 'log_file' was not declared in this scope; did you mean 'flockfile'?
  135 |             fflush(log_file);
      |                    ^~~~~~~~
      |                    flockfile
prison.cpp:28:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |     scanf("%d", &_n);
      |     ~~~~~^~~~~~~~~~~