답안 #311461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
311461 2020-10-10T09:48:29 Z IgorI 식물 비교 (IOI20_plants) C++17
컴파일 오류
0 ms 0 KB
+ 1, i);
    while (id != -1)
    {
        call(id, k, r, h1);
        id = CGet(i - k + 1, i);
    }
    h1[i] = c--;
    CAdd(i - k + 1, i, -1);
    CAdd(i, i + 1, INF);
}

void init(int k, vector<int> r)
{
    n = r.size();
    vector<int> h1(n);
    c = n;

    Build(0, n, 0, r);

    int id = CGet(0, n);
    while (id != -1)
    {
        call(id, k, r, h1);
        id = CGet(0, n);
    }
    for (int i = 0; i < n; i++)
    {
        H[i] = h1[i];
        //cout << H[i] << " ";
    }
    //cout << endl;
}

int compare_plants(int x, int y)
{
    if (H[x] > H[y]) return 1;
    return -1;
}

#ifdef LOCAL
int main()
{
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> r(n);
    for (int i = 0; i < n; i++) cin >> r[i];
    init(k, r);
    while (q--)
    {
        int x, y;
        cin >> x >> y;
        cout << compare_plants(x, y) << endl;
    }
}
#endif

Compilation message

plants.cpp:1:1: error: expected unqualified-id before '+' token
    1 | + 1, i);
      | ^
plants.cpp:2:5: error: expected unqualified-id before 'while'
    2 |     while (id != -1)
      |     ^~~~~
plants.cpp:7:5: error: 'h1' does not name a type
    7 |     h1[i] = c--;
      |     ^~
plants.cpp:8:9: error: expected constructor, destructor, or type conversion before '(' token
    8 |     CAdd(i - k + 1, i, -1);
      |         ^
plants.cpp:9:9: error: expected constructor, destructor, or type conversion before '(' token
    9 |     CAdd(i, i + 1, INF);
      |         ^
plants.cpp:10:1: error: expected declaration before '}' token
   10 | }
      | ^
plants.cpp:12:18: error: 'vector' has not been declared
   12 | void init(int k, vector<int> r)
      |                  ^~~~~~
plants.cpp:12:24: error: expected ',' or '...' before '<' token
   12 | void init(int k, vector<int> r)
      |                        ^
plants.cpp: In function 'void init(int, int)':
plants.cpp:14:5: error: 'n' was not declared in this scope
   14 |     n = r.size();
      |     ^
plants.cpp:14:9: error: 'r' was not declared in this scope
   14 |     n = r.size();
      |         ^
plants.cpp:15:5: error: 'vector' was not declared in this scope
   15 |     vector<int> h1(n);
      |     ^~~~~~
plants.cpp:15:12: error: expected primary-expression before 'int'
   15 |     vector<int> h1(n);
      |            ^~~
plants.cpp:16:5: error: 'c' was not declared in this scope
   16 |     c = n;
      |     ^
plants.cpp:18:5: error: 'Build' was not declared in this scope
   18 |     Build(0, n, 0, r);
      |     ^~~~~
plants.cpp:20:14: error: 'CGet' was not declared in this scope
   20 |     int id = CGet(0, n);
      |              ^~~~
plants.cpp:23:24: error: 'h1' was not declared in this scope
   23 |         call(id, k, r, h1);
      |                        ^~
plants.cpp:23:9: error: 'call' was not declared in this scope
   23 |         call(id, k, r, h1);
      |         ^~~~
plants.cpp:28:9: error: 'H' was not declared in this scope
   28 |         H[i] = h1[i];
      |         ^
plants.cpp:28:16: error: 'h1' was not declared in this scope
   28 |         H[i] = h1[i];
      |                ^~
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:36:9: error: 'H' was not declared in this scope
   36 |     if (H[x] > H[y]) return 1;
      |         ^