Submission #1036944

#TimeUsernameProblemLanguageResultExecution timeMemory
1036944XJP12Radio Towers (IOI22_towers)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "towers.h" using namespace std; typedef long long ll; typedef vector<int> vi; vi v; void init(int n, vi h) { v=h; } int max_towers(int l, int r, int d) { int ans=0; int v1=-1; int p1=-1; bool ban=false; for(int i=1; i<n; i++){ if(v[i]<v[i-1]){ if(p!=-1){ if(p1-v1>d){ p1=v1=-1; }else{ ban=true; } } } if(v[i]>v[i-1]){ if(ban==true){ ans++; ban=false; v1=v[i-1]; } if(v1==-1){ v1=v[i-1]; } p1=v[i]; } } return ans; }

Compilation message (stderr)

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:16:17: error: 'n' was not declared in this scope
   16 |  for(int i=1; i<n; i++){
      |                 ^
towers.cpp:18:7: error: 'p' was not declared in this scope
   18 |    if(p!=-1){
      |       ^