답안 #1015564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1015564 2024-07-06T14:17:47 Z nam6 송신탑 (IOI22_towers) C++17
컴파일 오류
0 ms 0 KB
#include "towers.h"
#include<bits/stdc++.h>
using namespace std; 

int sommet; 
vector<int> altitudes; 
vector< pair<int, int> > intervalle; 
set<int> choisis; 

const int DECA = 1<<22; 
arbre[2*DECA]; 

void modif(int pos, int val){
  pos+=DECA; 
  arbre[pos] = val; 
  while(pos > 1){
    pos/=2; 
    arbre[pos] = max(arbre[2*pos], arbre[2*pos+1]); 
  }
}

int calcMax(int deb, int fin){
  if(deb==fin)
    return arbre[fin]; 
  if(deb%2==1)
    return max(arbre[deb], calcMax(deb+1, fin)); 
  if(fin%2==0)
    return max(calcMax(deb, fin-1), fin); 
  return calcMax(deb/2, fin/2); 
}

void init(int N, vector<int> H) {
  altitudes = H; 
  
}

int max_towers(int L, int R, int D) {
  for(int pos=L; pos<=R; pos++){
    intervalle.push_back({altitudes[pos],pos}); 
  }
  sort(intervalle.begin(), intervalle.end()); 
  for(int i=0; i<intervalle.size(); i++){
    auto igauche = choisis.lower_bound(intervalle[i].second); *
    bool estOk = false; 
    if(igauche != choisis.begin()){
      igauche--; 
      int gauche = *igauche; 
      int maxiGauche = calcMax(gauche + MAXI, intervalle[i].second+MAXI); 
    }
    

    int droite= *choisis.upper_bound(intervalle[i].second); 
    
    int maxiDroite = calcMax(intervalle[i].second+MAXI, droite+MAXI); 
    if(maxiGauche - max(gauche, intervalle[i].second) >= D && maxiDroite- max(droite, intervalle[i].second) >= D){
      choisis.insert(intervalle[i].second);
    }
  }
  return 0;
}

Compilation message

towers.cpp:11:1: error: 'arbre' does not name a type
   11 | arbre[2*DECA];
      | ^~~~~
towers.cpp: In function 'void modif(int, int)':
towers.cpp:15:3: error: 'arbre' was not declared in this scope
   15 |   arbre[pos] = val;
      |   ^~~~~
towers.cpp: In function 'int calcMax(int, int)':
towers.cpp:24:12: error: 'arbre' was not declared in this scope
   24 |     return arbre[fin];
      |            ^~~~~
towers.cpp:26:16: error: 'arbre' was not declared in this scope
   26 |     return max(arbre[deb], calcMax(deb+1, fin));
      |                ^~~~~
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:42:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |   for(int i=0; i<intervalle.size(); i++){
      |                ~^~~~~~~~~~~~~~~~~~
towers.cpp:44:5: error: expected primary-expression before 'bool'
   44 |     bool estOk = false;
      |     ^~~~
towers.cpp:48:41: error: 'MAXI' was not declared in this scope
   48 |       int maxiGauche = calcMax(gauche + MAXI, intervalle[i].second+MAXI);
      |                                         ^~~~
towers.cpp:48:11: warning: unused variable 'maxiGauche' [-Wunused-variable]
   48 |       int maxiGauche = calcMax(gauche + MAXI, intervalle[i].second+MAXI);
      |           ^~~~~~~~~~
towers.cpp:54:51: error: 'MAXI' was not declared in this scope
   54 |     int maxiDroite = calcMax(intervalle[i].second+MAXI, droite+MAXI);
      |                                                   ^~~~
towers.cpp:55:8: error: 'maxiGauche' was not declared in this scope; did you mean 'igauche'?
   55 |     if(maxiGauche - max(gauche, intervalle[i].second) >= D && maxiDroite- max(droite, intervalle[i].second) >= D){
      |        ^~~~~~~~~~
      |        igauche
towers.cpp:55:25: error: 'gauche' was not declared in this scope; did you mean 'igauche'?
   55 |     if(maxiGauche - max(gauche, intervalle[i].second) >= D && maxiDroite- max(droite, intervalle[i].second) >= D){
      |                         ^~~~~~
      |                         igauche