当前位置:网站首页>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;
}
边栏推荐
- tuple and point
- GFS分布式文件系统
- [illumination du destin - 38]: Ghost Valley - chapitre 5 Flying clamp - one of the Warnings: There is a kind of killing called "hold Kill"
- Good documentation
- Marubeni Baidu applet detailed configuration tutorial, approved.
- Elfk deployment
- The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
- Bert fine tuning skills experiment
- Hmi-31- [motion mode] solve the problem of picture display of music module
- Open source SPL optimized report application coping endlessly
猜你喜欢

Missile interception -- UPC winter vacation training match

Practical case of SQL optimization: speed up your database

"C zero foundation introduction hundred knowledge and hundred cases" (72) multi wave entrustment -- Mom shouted for dinner

Can you really learn 3DMAX modeling by self-study?

Zabbix

openresty ngx_lua執行階段

Exploration of short text analysis in the field of medical and health (I)

A label colorful navigation bar

Avoid material "minefields"! Play with super high conversion rate

Summary and practice of knowledge map construction technology
随机推荐
d3js小记
[機緣參悟-38]:鬼穀子-第五飛箝篇 - 警示之一:有一種殺稱為“捧殺”
Naacl 2021 | contrastive learning sweeping text clustering task
Can you really learn 3DMAX modeling by self-study?
Exploration of short text analysis in the field of medical and health (I)
Hmi-32- [motion mode] add light panel and basic information column
Pytorch register_ Hook (operate on gradient grad)
【LeetCode】404. Sum of left leaves (2 brushes of wrong questions)
Design and implementation of campus epidemic prevention and control system based on SSM
Word processing software
Some query constructors in laravel (2)
Matrixone 0.2.0 is released, and the fastest SQL computing engine is coming
TCP security of network security foundation
The steering wheel can be turned for one and a half turns. Is there any difference between it and two turns
Scientific research: are women better than men?
Video display and hiding of imitation tudou.com
Asynchronous and promise
Hmi-31- [motion mode] solve the problem of picture display of music module
使用druid連接MySQL數據庫報類型錯誤
[Yu Yue education] National Open University spring 2019 0505-22t basic nursing reference questions