当前位置:网站首页>Acwing第 58 场周赛【完结】
Acwing第 58 场周赛【完结】
2022-07-05 02:37:00 【辉小歌】
没打,赛后vp了一下题目好简单。
15min做完
https://www.acwing.com/activity/content/competition/problem_list/1994/、
4488. 寻找1【签到】
#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. 最长子序列【贪心 / 双指针】

#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. 染色【思维】

画图,你会发现只要其颜色和父亲颜色不一样就加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;
}
边栏推荐
- Rabbit MQ message sending of vertx
- Character painting, I use characters to draw a Bing Dwen Dwen
- Missile interception -- UPC winter vacation training match
- When the low alcohol race track enters the reshuffle period, how can the new brand break the three major problems?
- ELK日志分析系统
- Binary tree traversal - middle order traversal (golang)
- 平台入驻与独立部署优缺点对比
- A label making navigation bar
- 【LeetCode】404. Sum of left leaves (2 brushes of wrong questions)
- Kotlin - 协程 Coroutine
猜你喜欢

The steering wheel can be turned for one and a half turns. Is there any difference between it and two turns

Variables in postman

Asynchronous and promise

Missile interception -- UPC winter vacation training match
![[technology development-26]: data security of new information and communication networks](/img/13/10c8bd340017c6516edef41cd3bf6f.png)
[technology development-26]: data security of new information and communication networks
![Moco V2 literature research [self supervised learning]](/img/bd/79b7b203ea064c65d143116c9f4dd0.jpg)
Moco V2 literature research [self supervised learning]

Yuan universe also "real estate"? Multiple second-hand trading websites block metauniverse keywords

【LeetCode】222. The number of nodes of a complete binary tree (2 mistakes)

Visual explanation of Newton iteration method

Openresty ngx Lua Execution stage
随机推荐
The phenomenology of crypto world: Pioneer entropy
Rabbit MQ message sending of vertx
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
Structure of ViewModel
openresty ngx_ Lua execution phase
d3js小记
RichView TRVStyle MainRVStyle
Talk about the things that must be paid attention to when interviewing programmers
spoon插入更新oracle数据库,插了一部分提示报错Assertion botch: negative time
Which common ports should the server open
Start the remedial work. Print the contents of the array using the pointer
Chinese natural language processing, medical, legal and other public data sets, sorting and sharing
Action News
【附源码】基于知识图谱的智能推荐系统-Sylvie小兔
A label making navigation bar
Yuan universe also "real estate"? Multiple second-hand trading websites block metauniverse keywords
[機緣參悟-38]:鬼穀子-第五飛箝篇 - 警示之一:有一種殺稱為“捧殺”
Erreur de type de datagramme MySQL en utilisant Druid
【LeetCode】106. Construct binary tree from middle order and post order traversal sequence (wrong question 2)
打破信息茧房-我主动获取信息的方法 -#3