답안 #377580

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
377580 2021-03-14T10:28:09 Z marat0210 식물 비교 (IOI20_plants) C++14
컴파일 오류
0 ms 0 KB
#include <plants.h>
#include <bits/stdc++.h>

using namespace std;

vector <int> s;
int n;

void init(int k, vector <int> r)
{
    n = r.size();
    s.push_back(0);
    for (int i: r) {
        s.push_back(s.back() + i);
    }
}

int compare_plants(int x, y)
{
    if (x > y) return -compare_plants(y, x);
    if (s[x] == s[y]) return 1;
    if (s[y] == s[n] and s[0] == s[x]) return -1;
    if (s[x] - x == s[y] - y) return -1;
    if (s[y] - y == s[n] - n and s[0] == s[x] - x) return 1;
    return 0;
}




Compilation message

plants.cpp:18:27: error: 'y' has not been declared
   18 | int compare_plants(int x, y)
      |                           ^
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:20:13: error: 'y' was not declared in this scope
   20 |     if (x > y) return -compare_plants(y, x);
      |             ^
plants.cpp:21:19: error: 'y' was not declared in this scope
   21 |     if (s[x] == s[y]) return 1;
      |                   ^
plants.cpp:22:11: error: 'y' was not declared in this scope
   22 |     if (s[y] == s[n] and s[0] == s[x]) return -1;
      |           ^
plants.cpp:23:23: error: 'y' was not declared in this scope
   23 |     if (s[x] - x == s[y] - y) return -1;
      |                       ^
plants.cpp:24:11: error: 'y' was not declared in this scope
   24 |     if (s[y] - y == s[n] - n and s[0] == s[x] - x) return 1;
      |           ^