当前位置:网站首页>Acwing game 58 [End]
Acwing game 58 [End]
2022-07-05 02:38:00 【Hui Xiaoge】
Didn't fight , After the game vp The topic is so simple .
15min finish
https://www.acwing.com/activity/content/competition/problem_list/1994/、
Catalog
4488. seek 1【 Sign in 】
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
int n,x,flag=0;
cin>>n;
while(n--)
{
cin>>x;
if(x) flag=1;
}
if(flag) puts("YES");
else puts("NO");
return 0;
}
4489. The longest subsequence 【 greedy / Double pointer 】

#include<bits/stdc++.h>
using namespace std;
const int N=1e5*3+10;
int n,a[N];
int main(void)
{
cin>>n;
for(int i=1;i<=n;i++) cin>>a[i];
int cnt=1,last=1,ans=1;
for(int i=2;i<=n;i++)
{
if(a[i]<=a[last]*2) cnt++,last=i;
else last=i,cnt=1;
ans=max(ans,cnt);
}
cout<<ans;
return 0;
}
4490. dyeing 【 thinking 】

drawing , You will find that as long as the color is different from that of your father, you can add it 1.
#include<bits/stdc++.h>
using namespace std;
const int N=1e5*3+10;
int h[N],e[N],ne[N],idx;
int w[N],n,cnt=1;
void add(int a,int b)
{
e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}
void dfs(int u,int fa)
{
if(fa!=-1&&w[u]!=w[fa]) cnt++;
for(int i=h[u];i!=-1;i=ne[i])
{
int j=e[i];
if(j==fa) continue;
dfs(j,u);
}
}
int main(void)
{
memset(h,-1,sizeof h);
cin>>n;
for(int i=2;i<=n;i++)
{
int x; cin>>x;
add(x,i),add(i,x);
}
for(int i=1;i<=n;i++) cin>>w[i];
dfs(1,-1);
cout<<cnt;
return 0;
}
边栏推荐
- openresty ngx_lua执行阶段
- Talk about the things that must be paid attention to when interviewing programmers
- Exploration of short text analysis in the field of medical and health (II)
- Yolov5 model training and detection
- 【微服务|SCG】Filters的33种用法
- Zabbix
- [机缘参悟-38]:鬼谷子-第五飞箝篇 - 警示之一:有一种杀称为“捧杀”
- How to find hot projects in 2022? Dena community project progress follow-up, there is always a dish for you (1)
- Design and implementation of high availability website architecture
- The MySQL team development specifications used by various factories are too detailed. It is recommended to collect them!
猜你喜欢
![Hmi-32- [motion mode] add light panel and basic information column](/img/9c/0b25c0a41758652848aed2a269880f.jpg)
Hmi-32- [motion mode] add light panel and basic information column
![Hmi-31- [motion mode] solve the problem of picture display of music module](/img/9c/0b25c0a41758652848aed2a269880f.jpg)
Hmi-31- [motion mode] solve the problem of picture display of music module

Visual explanation of Newton iteration method

The MySQL team development specifications used by various factories are too detailed. It is recommended to collect them!

CAM Pytorch

openresty ngx_ Lua execution phase

Yolov5 model training and detection

Elk log analysis system

Practical case of SQL optimization: speed up your database

Asynchronous and promise
随机推荐
Unpool(nn.MaxUnpool2d)
When the low alcohol race track enters the reshuffle period, how can the new brand break the three major problems?
Elfk deployment
[source code attached] Intelligent Recommendation System Based on knowledge map -sylvie rabbit
TCP security of network security foundation
GFS distributed file system
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
数据库和充值都没有了
Binary tree traversal - middle order traversal (golang)
【附源码】基于知识图谱的智能推荐系统-Sylvie小兔
Zabbix
Last words record
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
Design and implementation of community hospital information system
Hmi-31- [motion mode] solve the problem of picture display of music module
Learn game model 3D characters, come out to find a job?
Subject 3 how to turn on the high beam diagram? Is the high beam of section 3 up or down
Application and Optimization Practice of redis in vivo push platform
tuple and point
From task Run get return value - getting return value from task Run