Submission #1036943

# Submission time Handle Problem Language Result Execution time Memory
1036943 2024-07-27T20:21:03 Z XJP12 Radio Towers (IOI22_towers) C++17
Compilation error
0 ms 0 KB
#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 p=-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

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:19:8: error: 'p1' was not declared in this scope; did you mean 'p'?
   19 |     if(p1-v1>d){
      |        ^~
      |        p
towers.cpp:35:4: error: 'p1' was not declared in this scope; did you mean 'p'?
   35 |    p1=v[i];
      |    ^~
      |    p