제출 #1036944

#제출 시각아이디문제언어결과실행 시간메모리
1036944XJP12송신탑 (IOI22_towers)C++17
컴파일 에러
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; }

컴파일 시 표준 에러 (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){
      |       ^