当前位置:网站首页>1.19 learning summary
1.19 learning summary
2022-06-26 04:35:00 【After all, I still walk alone】
I have finished all the topics today . Just do the problem solving , When reviewing . I did a question today . I think it's more interesting . The title is as follows .

This question is very interesting . The main requirement is the middle order . The title also tells us . The middle order is not fixed . In fact, if you carefully observe the conditions given by the topic , You will find that this sample actually gives you a hint . The example shows three elements . But we know these three elements . A forest of trees Depth of three . Why? ? You can observe it . According to the requirements of the preceding sequence . Behind the root It's a left-right subtree ,. And in the following sequence , In front of the root are left and right subtrees . Therefore, whether it is pre order or post order The left and right sides of the subtree do not change . But in The example changes . That means they are not left or right Subtree relation . But the root And child nodes . And it has only one child node . This nature It is also the key for me to solve this problem . My method is to traverse Find from . Want to bccb Such . Find one . That means there are two possibilities . That is to the power of two ? This is my idea of doing this problem .
#include<stdio.h>
#include<string.h>
#include<math.h>
int ans;
char str1[500],str2[500];
int main()
{
scanf("%s",str1);
scanf("%s",str2);
int m=strlen(str1);
int m1=strlen(str2);
for(int i=0;i<m;i++){
for(int j=m1-1;j>0;j--){
if(str1[i]==str2[j]&&str1[i+1]==str2[j-1]){
ans++;}}}
int s;
s=pow(2,ans);
printf("%d",s);
return 0;
}There is also a topic of joint search , I want to say .
The title is as follows .

This topic has two sets of data . So I used two parallel search sets . Merge their relationships separately . Then traverse to find out all that are related to Xiao Ming and Xiao Hong Common ancestor data . So I found . Two companies , Xiao Ming and Xiao Hong's friends .
The only trouble is . The other group is negative . So we have to deal with it in a little way . I am turning him into a positive number . Add one more n.
The specific code is as follows . This question is still relatively simple .
#include<stdio.h>
#include <algorithm>
using namespace std;
int n,m,p,q,ansm=0,ans1=0,f[1000000];
int find(int x)
{
if(f[x]==x){
return x;}
else {
f[x]=find(f[x]);
return f[x];}
}
void s(int x,int y)
{
f[find(x)]=find(y);
}
int main()
{
scanf("%d%d%d%d",&n,&m,&p,&q);
for(int i=1;i<=n+m;++i)
f[i]=i;
for(int i=1;i<=p;++i)
{
int a,b;
scanf("%d%d",&a,&b);
s(a,b);
}
for(int i=1;i<=q;++i)
{
int a,b;
scanf("%d%d",&a,&b);
a*=-1;b*=-1;
s(a+n,b+n);
}
for(int i=1;i<=n;++i){
if(find(i)==find(1)){
ansm++;}}
for(int i=n+1;i<=n+m;++i){
if(find(i)==find(n+1)){
ans1++;}}
printf("%d",min(ans1,ansm));
return 0;
}边栏推荐
- Introduction to markdown grammar
- ctf [RoarCTF 2019]easy_ calc
- Thinkphp6 using kindeditor
- Knowledge of SQL - database design, backup and restore
- OSS CDN alicloud configuration method
- 企业的产品服务怎么进行口碑营销?口碑营销可以找人代做吗?
- Analysis report on development trend and market demand of global and Chinese molecular diagnostics industry from 2022 to 2028
- Zhubo Huangyu: you can try these non-agricultural operation skills
- Tp6 is easy to tread [original]
- Swagger
猜你喜欢
![There is no response to redirection and jump in the laravel constructor [original]](/img/6b/5d9d7fe1348892d01a87d04f122dfc.jpg)
There is no response to redirection and jump in the laravel constructor [original]

Mysql8.0 configuring my SQL in INI file_ mode=NO_ AUTO_ CREATE_ User can start

MySQL index details

Microsoft prohibits Russian users from downloading and installing win10/11
![[Qunhui] import certificate](/img/1f/ab63b0556a60b98388b482d70f6156.jpg)
[Qunhui] import certificate

08_ Spingboot integrated redis
![Alipay failed to verify the signature (sandbox test indicates fishing risk?) [original]](/img/64/c3bb27a3711a6f0cc7b281d1a961af.jpg)
Alipay failed to verify the signature (sandbox test indicates fishing risk?) [original]
![[Qunhui] Internet access + custom port](/img/7d/c00caeade209a48c8f44a4fecb59d5.jpg)
[Qunhui] Internet access + custom port

Threejs special sky box materials, five kinds of sky box materials are downloaded for free

Database design (I)
随机推荐
What is the best way to store chat messages in a database? [Close] - best way to store chat messages in a database? [closed]
Be a hard worker from today on
numpy 随机数
问题随记 —— pip 换源
Sixtool- source code of multi-functional and all in one generation hanging assistant
Tp6 controller does not exist: app\index\controller\index
08_ Spingboot integrated redis
2021-02-07
Redis cluster mode
Understand CGI and fastcgi
Oracle data pump table
NPM installation tutorial
Motivational skills for achieving goals
Laravel pay payment access process
Ubuntu installs PostgreSQL and uses omnidb to view
Install SVN in Pagoda and build SVN version Library
做软件测试学历重要还是能力重要
CTF crypto (I) some simple encoding and encryption
Gateway can not connect to tcp://127.0.0.1: Connection refused
Using jsup to extract images from interfaces