제출 #762289

#제출 시각아이디문제언어결과실행 시간메모리
762289raysh07송신탑 (IOI22_towers)C++17
컴파일 에러
0 ms0 KiB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;

int k;
vector <int> a;

void init(int N, vector<int> H) {
    k = -1;
    for (int i = 0; i < N; i++){
        bool good = true;
        if (i != 0) good &= H[i] > H[i - 1];
        if (i != N - 1) good &= H[i] > H[i + 1];
        
        if (good) k = i;
    }
    a = H;
    assert(k != -1);
}

int max_towers(int L, int R, int D) {
    if (L < k && R > k) {
        if (a[L] <= a[k] - D && a[r] <= a[k] - D) return 2;
        else return 1;
    }
    else return 1;
}

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

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:23:35: error: 'r' was not declared in this scope
   23 |         if (a[L] <= a[k] - D && a[r] <= a[k] - D) return 2;
      |                                   ^