제출 #1040827

#제출 시각아이디문제언어결과실행 시간메모리
1040827nightfal식물 비교 (IOI20_plants)C++14
컴파일 에러
0 ms0 KiB
#include "plants.h" static std:: vector<int> inc,dec; void init(int k, std::vector<int> r) { int n = r.size(); if(k==2) { inc.resize(n); dec.resize(n); for(int i=0; i<n; i++) {inc[i] = dec[i] = i;} int s,incVal,decVal; for(s=2*n-1; s>=0; s--) { if (r[s%n]==0) incVal = s; else decVal = s; inc[s%n] = incVal; dec[s%n] = decVal; } } return; } int subtask1(int x, int y) { if (y <= dec[x] or x+n <= inc[y]) return 1; else if (y <= inc[x] or x+n <= dec[y]) return -1; return 0; } int compare_plants(int x, int y) { if (k==2) return subtask1(x,y); return 0; }

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

plants.cpp: In function 'int subtask1(int, int)':
plants.cpp:19:26: error: 'n' was not declared in this scope
   19 |     if (y <= dec[x] or x+n <= inc[y]) return 1;
      |                          ^
plants.cpp: In function 'int compare_plants(int, int)':
plants.cpp:24:8: error: 'k' was not declared in this scope
   24 |    if (k==2) return subtask1(x,y);
      |        ^