제출 #568463

#제출 시각아이디문제언어결과실행 시간메모리
568463hollwo_pelw코알라 (APIO17_koala)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #include "koala.h" int R[105], B[105]; void __init__() { memset(R, 0, sizeof R); memset(B, 0, sizeof B); } int minValue(int N, int W) { __init__(); B[0] = 1; playRound(B, R); for (int i = 1; i < N; i++) if (!R[i]) return i; return 0; } int maxValue(int N, int W) { vector<int> res(N); iota(res.begin(), res.end(), 0); while ((int) res.size() > 1) { __init__(); for (auto i : res) B[i] = W / res.size(); playRound(B, R); int f = *max_element(R, R + N); res.clear(); for (int i = 0; i < N; i++) if (R[i] == f) res.push_back(i); } return res[0]; } int greaterValue(int N, int W) { int l = 0, r = sqrt(N * 2); while (l <= r) { int mid = (l + r) >> 1; __init__(); B[0] = B[1] = mid; playRound(B, R); int c0 = R[0] > B[0], c1 = R[1] > B[1]; if (c0 ^ c1) { if (c0) return 0; if (c1) return 1; } if (c0) { l = mid + 1; } else { r = mid - 1; } } return 0; } void solve(int L, int R, int W, int *P, vector<int> pos) { if (L == R) { assert((int) pos.size() == 1); return P[pos[0]] = L, (void) 0; } vector<int> lef, rig; __init__(); for (int i : pos) B[i] = W / pos.size(); playRound(B, R); for (int i : pos) { if (R[i] > B[i]) rig.push_back(i); else lef.push_back(i); } int mid = L + lef.size() - 1; solve(L, mid, lef), solve(mid + 1, R, rig); } void allValues(int N, int W, int *P) { vector<int> pos(N); iota(pos.begin(), pos.end(), 0); if (W == 2*N) { solve(1, N, W, P, pos); } else { solve(1, N, W, P, pos); } }

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

koala.cpp: In function 'void solve(int, int, int, int*, std::vector<int>)':
koala.cpp:78:15: error: invalid conversion from 'int' to 'int*' [-fpermissive]
   78 |  playRound(B, R);
      |               ^
      |               |
      |               int
In file included from koala.cpp:4:
koala.h:4:29: note:   initializing argument 2 of 'void playRound(int*, int*)'
    4 | void playRound(int *B, int *R);
      |                        ~~~~~^
koala.cpp:81:8: error: invalid types 'int[int]' for array subscript
   81 |   if (R[i] > B[i])
      |        ^
koala.cpp:87:16: error: cannot convert 'std::vector<int>' to 'int'
   87 |  solve(L, mid, lef), solve(mid + 1, R, rig);
      |                ^~~
      |                |
      |                std::vector<int>
koala.cpp:67:30: note:   initializing argument 3 of 'void solve(int, int, int, int*, std::vector<int>)'
   67 | void solve(int L, int R, int W, int *P, vector<int> pos) {
      |                          ~~~~^
koala.cpp:87:40: error: cannot convert 'std::vector<int>' to 'int'
   87 |  solve(L, mid, lef), solve(mid + 1, R, rig);
      |                                        ^~~
      |                                        |
      |                                        std::vector<int>
koala.cpp:67:30: note:   initializing argument 3 of 'void solve(int, int, int, int*, std::vector<int>)'
   67 | void solve(int L, int R, int W, int *P, vector<int> pos) {
      |                          ~~~~^