제출 #572786

#제출 시각아이디문제언어결과실행 시간메모리
572786kartelComparing Plants (IOI20_plants)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> //#include "grader.cpp" #include "plants.h" #define pb push_back #define sz(x) (int)x.size() using namespace std; const int N = 1e6 + 500; int le[N], ri[N]; void init(int k, vector <int> r) { int n = sz(r); vector <vector <int> > g(n); for (int i = 0; i < n * 3; i++) { if (!r[i % n]) { le[i] = (i - 1 >= 0 ? le[i - 1] : -1); } else { le[i] = i; } } for (int i = n * 3 - 1; i >= 0; i--) { if (r[i % n]) { ri[i] = ri[i + 1]; } else { ri[i] = i; } } } int compare_plants(int x, int y) { if (le[x + n] <= y && y <= ri[x + n]) { return 1; } if (le[x + n] <= y + n && y + n <= ri[x + n]) { return 1; } if (le[x + n] <= y + 2 * n && y + 2 * n <= ri[x + n]) { return 1; } if (le[y + n] <= x && x <= ri[y + n]) { return -1; } if (le[y + n] <= x + n && x + n <= ri[y + n]) { return -1; } if (le[y + n] <= x + 2 * n && x + 2 * n <= ri[y + n]) { return -1; } return 0; }

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

plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:35:16: error: 'n' was not declared in this scope
   35 |     if (le[x + n] <= y && y <= ri[x + n]) {
      |                ^
plants.cpp:38:16: error: 'n' was not declared in this scope
   38 |     if (le[x + n] <= y + n && y + n <= ri[x + n]) {
      |                ^
plants.cpp:41:16: error: 'n' was not declared in this scope
   41 |     if (le[x + n] <= y + 2 * n && y + 2 * n <= ri[x + n]) {
      |                ^
plants.cpp:45:16: error: 'n' was not declared in this scope
   45 |     if (le[y + n] <= x && x <= ri[y + n]) {
      |                ^
plants.cpp:48:16: error: 'n' was not declared in this scope
   48 |     if (le[y + n] <= x + n && x + n <= ri[y + n]) {
      |                ^
plants.cpp:51:16: error: 'n' was not declared in this scope
   51 |     if (le[y + n] <= x + 2 * n && x + 2 * n <= ri[y + n]) {
      |                ^