Submission #762289

# Submission time Handle Problem Language Result Execution time Memory
762289 2023-06-21T09:02:36 Z raysh07 Radio Towers (IOI22_towers) C++17
Compilation error
0 ms 0 KB
#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;
}

Compilation message

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;
      |                                   ^