当前位置:网站首页>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;
}
边栏推荐
- Avoid material "minefields"! Play with super high conversion rate
- When to catch an exception and when to throw an exception- When to catch the Exception vs When to throw the Exceptions?
- openresty ngx_lua執行階段
- spoon插入更新oracle数据库,插了一部分提示报错Assertion botch: negative time
- Kotlin - coroutine
- Erreur de type de datagramme MySQL en utilisant Druid
- Redis distributed lock, lock code logic
- Kotlin - 协程 Coroutine
- [技术发展-26]:新型信息与通信网络的数据安全
- Design of kindergarten real-time monitoring and control system
猜你喜欢

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

Android advanced interview question record in 2022

A label colorful navigation bar

Learn game model 3D characters, come out to find a job?

spoon插入更新oracle数据库,插了一部分提示报错Assertion botch: negative time

Scientific research: are women better than men?
![[200 opencv routines] 99 Modified alpha mean filter](/img/df/1b7beb6746f416198fc405249852f8.jpg)
[200 opencv routines] 99 Modified alpha mean filter

Application and Optimization Practice of redis in vivo push platform

Character painting, I use characters to draw a Bing Dwen Dwen

Application and Optimization Practice of redis in vivo push platform
随机推荐
Why do you understand a16z? Those who prefer Web3.0 Privacy Infrastructure: nym
Introduce reflow & repaint, and how to optimize it?
He was laid off.. 39 year old Ali P9, saved 150million
openresty ngx_ Lua variable operation
Naacl 2021 | contrastive learning sweeping text clustering task
Problem solving: attributeerror: 'nonetype' object has no attribute 'append‘
[uc/os-iii] chapter 1.2.3.4 understanding RTOS
Application and Optimization Practice of redis in vivo push platform
LeetCode --- 1071. Great common divisor of strings problem solving Report
[technology development-26]: data security of new information and communication networks
tuple and point
丸子百度小程序详细配置教程,审核通过。
The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
D3js notes
The database and recharge are gone
如何做一个炫酷的墨水屏电子钟?
Pytest (5) - assertion
Pgadmin 4 V6.5 release, PostgreSQL open source graphical management tool
Openresty ngx Lua Execution stage
Unpool(nn.MaxUnpool2d)