当前位置:网站首页>P5076 [Fondation profonde 16. Exemple 7] Arbre binaire commun (version simplifiée)
P5076 [Fondation profonde 16. Exemple 7] Arbre binaire commun (version simplifiée)
2022-06-12 20:11:00 【Recurss】
【Base profonde16.Exemple7】Arbre binaire ordinaire(Version simplifiée) - La vallée de lo
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<set>
using namespace std;
multiset<int>q;
int n,t,x,order;
int main()
{
q.insert(-0x7fffffff);
q.insert(0x7fffffff);
//Mettez - les à l'avance.,Éviter les erreurs
scanf("%d",&n);
while(n--)
{
scanf("%d%d",&t,&x);
if(t==1)
{
auto it=q.lower_bound(x);
//autoEst de juger automatiquement le type de données,SeulementC++14C'est tout ce qui précède.
//Peut écriremultiset<int>::iterator,Parce quelower_boundLa méthode renvoie l'Itérateur
// it Accès x Emplacement
order=0;
//orderClassement
for(auto i=q.begin();i!=it;i++,order++);
//Ici.autoMême chose.,C'est aussi un Itérateur
// C'est réglé ici xClassement——order
printf("%d\n",order);
//ProduitsorderC'est la réponse
}
else if(t==2)
{
order=-1;
//La valeur initiale est-1 C'est parce qu'il y a un -0x7fffffff,Alors...order Pour faire un pas de plus
for(int i:q)
if(++order==x)
//Abréviations,order Un de plus , Pour déterminer si xÉquivalence
//Si oui(order++==x), C'est - à - dire juger avant d'augmenter , Faites attention ici
printf("%d\n",i);
//i C'est la valeur dans le conteneur ,Produitsi
//Attention icifor(:)Cycle,Oui, seulementC++11 C'est ce qui est supporté
//EtautoC'est pareil,Tous.noipÇa ne marche pas.
//Ce cycle,i C'est la valeur dans le conteneur, pas l'indice
// Vous pouvez également utiliser la boucle itératrice , La boucle ci - dessus est équivalente à
/*
for(multiset<int>::iterator it=q.begin();it!=q.end();it++)
{
order++;
if(order==x)
printf("%d\n",*it);
}
*/
// Ce cycle est noipDisponible
}
else if(t==3)
{
auto it=q.lower_bound(x);
// Obtenir le premier supérieur ou égal à xValeur de
//C'est le premier.xEmplacement
// Parce qu'on va avoir un avant - garde ,Alors...it - un de moins.
printf("%d\n",*--it);
// Cette phrase est d'abord auto - soustraite ,Réexportation,C'est une abréviation.
//Équivalent à:
/*
it--;
printf("%d\n",*it);
*/
// Parce que c'est l'Itérateur (Pointeur), Donc la sortie est précédée de *
}
else if(t==4)
{
printf("%d\n",*q.upper_bound(x));
// Pour obtenir un successeur ,Est le premier plus grand quexValeur de
//Avecupper_bound La méthode obtient le premier plus grand que xItérateur pour
//La sortie suffit
// Parce que c'est l'Itérateur (Pointeur), Donc la sortie est précédée de *
}
else
{
q.insert(x);
//Il suffit de l'ajouter directement
}
}
return 0;
}边栏推荐
- Detailed explanation of IO flow basic knowledge -- file and IO flow principle
- System log
- Demand and business model analysis-1-business model canvas
- JDBC接口总结
- 【GAMES101】课堂笔记8–着色(着色频率、图形管线、纹理映射)
- Explain
- 94. analyze the content in the web page
- QT -- how to get the contents of selected cells in qtableview
- The joint empowerment plan of Baidu PaddlePaddle large enterprise open innovation center was launched! Help Pudong to upgrade its industry intelligently
- Golang type assertion understanding [go language Bible]
猜你喜欢

Macro definitions and functions

Demand and business model innovation - demand 1 - Introduction to demand engineering

2022年,中国大学生最多的20个城市

In 2022, FISCO bcos MVP recognized that the channel was open and invited you to become an open source leader

Index optimization principle

Reading small program based on wechat e-book graduation design (4) opening report

Promise to solve hell function calls can be used infinitely

A simple understanding of consistent hash

system()

Microsoft Word 教程,如何在 Word 中插入页眉或页脚?
随机推荐
Compilation of programs
代理与反射
What is disk IO?
Wechat jsapi payment pit summary
Efcore tuning
Wall Street cheat sheet
EFCore调优
Programming tool download address
Viewpoint sharing | Li Wei, an expert of Gewu titanium intelligent technology products: underlying logic and scenario practice of unstructured data platform
Demand and business model innovation - demand 1 - Introduction to demand engineering
Wechat e-book reading applet graduation design completion works (8) graduation design thesis template
Download and configuration of nuitka packaging tutorial
Implementation of exec function and shell
Torch network model is converted to onnx format and visualized
Reading applet based on wechat e-book graduation design (2) applet function
exec函数、shell的实现
系统 日志
WordPress station group tutorial automatic collection of pseudo original release tutorial
PostgreSQL database replication - background first-class citizen process walreceiver PG_ stat_ wal_ Receiver view
MySQL index classification