当前位置:网站首页>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;
}边栏推荐
- Notes on enterprise wechat development [original]
- Redis cache data consistency solution analysis
- Knowledge about SQL - DML
- numpy 随机数
- Resolve PHP is not an internal or external command
- Minecraft 1.16.5 biochemical 8 module 1.9 version 1.18 version synchronization
- What are the advantages and risks of paper gold investment
- Create alicloud test instances
- Thinkphp6 using kindeditor
- Navicat connects the pit of shardingsphere sub table and sub library plug-ins
猜你喜欢

Tp6 multi table Association (table a is associated with table B, table B is associated with table C, and table d)

Construction of art NFT trading platform | NFT mall

mysql高级学习(跟着尚硅谷老师周阳学习)

Minecraft 1.16.5 biochemical 8 module 1.9 version 1.18 version synchronization
![[H5 development] 01 take you to experience H5 development from a simple page ~ the whole page implementation process from static page to interface adjustment manual teaching](/img/e4/27611abdd000019e70f4447265808c.jpg)
[H5 development] 01 take you to experience H5 development from a simple page ~ the whole page implementation process from static page to interface adjustment manual teaching

Computer network high frequency interview questions

Modify the number of Oracle connections
![[Qunhui] import certificate](/img/1f/ab63b0556a60b98388b482d70f6156.jpg)
[Qunhui] import certificate

Implementation of seven classes of BlockingQueue interface

Gateway can not connect to tcp://127.0.0.1: Connection refused
随机推荐
Alipay failed to verify the signature (sandbox test indicates fishing risk?) [original]
Clean up photo SCR virus / iframekill injection removal /iframekill removal photo scr
小程序中实现视频通话及互动直播功能
35岁程序员炒Luna 千万资产3天归零,网友:和赌博一样
Knowledge of functions
Development prospect and investment strategic planning report of global and Chinese PVC hose industry from 2022 to 2028
[H5 development] 02 take you to develop H5 list page ~ including query, reset and submission functions
C generic
Laravel access error could not be opened
Use shell script to analyze system CPU, memory and network throughput
2021-01-31
mysql高级学习(跟着尚硅谷老师周阳学习)
Laravel pay payment access process
Be a hard worker from today on
Parse JSON interface and insert it into the database in batch
SSH password free login, my server password free login to the other server, the other server password free login to your server
[Qunhui] command line acme SH automatically apply for domain name certificate
PHP splits a string into arrays
List of provinces, cities and counties in China
Using jsup to extract images from interfaces