답안 #723198

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
723198 2023-04-13T10:23:38 Z nguyentunglam 코알라 (APIO17_koala) C++17
컴파일 오류
0 ms 0 KB
bool cmp(const int &x, const int &y) {
    for(int i = 0; i < n; i++) b[i] = 0;
    b[x] = w / 2; b[y] = w / 2;
    playRound(b, c);
    return c[x] < c[y];
}

void allValues(int _n, int W, int *P) {
    n = _n;
    w = W;
    if (W == 2 * n) {
        for(int i = 0; i < n; i++) order[i] = i;
        sort(order, order + n, cmp);
        for(int i = 0; i < n; i++) P[order[i]] = i + 1;
    } else {
        vector<int> init;
        for(int i = 0; i < n; i++) init.push_back(i);
        solve(init, 1, n);
        for(int i = 0; i < n; i++) P[i] = ans[i];
    }
}

Compilation message

koala.cpp: In function 'bool cmp(const int&, const int&)':
koala.cpp:2:24: error: 'n' was not declared in this scope
    2 |     for(int i = 0; i < n; i++) b[i] = 0;
      |                        ^
koala.cpp:2:32: error: 'b' was not declared in this scope
    2 |     for(int i = 0; i < n; i++) b[i] = 0;
      |                                ^
koala.cpp:3:5: error: 'b' was not declared in this scope
    3 |     b[x] = w / 2; b[y] = w / 2;
      |     ^
koala.cpp:3:12: error: 'w' was not declared in this scope
    3 |     b[x] = w / 2; b[y] = w / 2;
      |            ^
koala.cpp:4:18: error: 'c' was not declared in this scope
    4 |     playRound(b, c);
      |                  ^
koala.cpp:4:5: error: 'playRound' was not declared in this scope
    4 |     playRound(b, c);
      |     ^~~~~~~~~
koala.cpp: In function 'void allValues(int, int, int*)':
koala.cpp:9:5: error: 'n' was not declared in this scope; did you mean '_n'?
    9 |     n = _n;
      |     ^
      |     _n
koala.cpp:10:5: error: 'w' was not declared in this scope
   10 |     w = W;
      |     ^
koala.cpp:12:36: error: 'order' was not declared in this scope
   12 |         for(int i = 0; i < n; i++) order[i] = i;
      |                                    ^~~~~
koala.cpp:13:14: error: 'order' was not declared in this scope
   13 |         sort(order, order + n, cmp);
      |              ^~~~~
koala.cpp:13:9: error: 'sort' was not declared in this scope; did you mean 'short'?
   13 |         sort(order, order + n, cmp);
      |         ^~~~
      |         short
koala.cpp:16:9: error: 'vector' was not declared in this scope
   16 |         vector<int> init;
      |         ^~~~~~
koala.cpp:16:16: error: expected primary-expression before 'int'
   16 |         vector<int> init;
      |                ^~~
koala.cpp:17:36: error: 'init' was not declared in this scope; did you mean 'int'?
   17 |         for(int i = 0; i < n; i++) init.push_back(i);
      |                                    ^~~~
      |                                    int
koala.cpp:18:15: error: 'init' was not declared in this scope; did you mean 'int'?
   18 |         solve(init, 1, n);
      |               ^~~~
      |               int
koala.cpp:18:9: error: 'solve' was not declared in this scope
   18 |         solve(init, 1, n);
      |         ^~~~~
koala.cpp:19:43: error: 'ans' was not declared in this scope
   19 |         for(int i = 0; i < n; i++) P[i] = ans[i];
      |                                           ^~~