当前位置:网站首页>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;
}
边栏推荐
- Medusa installation and simple use
- Video display and hiding of imitation tudou.com
- Last week's hot review (2.7-2.13)
- Variables in postman
- Blue bridge - maximum common divisor and minimum common multiple
- Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
- Unpool(nn.MaxUnpool2d)
- 2022/02/13
- ICSI 311 Parser
- Binary tree traversal - middle order traversal (golang)
猜你喜欢
Chinese natural language processing, medical, legal and other public data sets, sorting and sharing
Pytest (4) - test case execution sequence
[technology development-26]: data security of new information and communication networks
Visual studio 2019 set transparent background (fool teaching)
问题解决:AttributeError: ‘NoneType‘ object has no attribute ‘append‘
Grub 2.12 will be released this year to continue to improve boot security
Elk log analysis system
Summary and practice of knowledge map construction technology
[200 opencv routines] 99 Modified alpha mean filter
Introduce reflow & repaint, and how to optimize it?
随机推荐
The steering wheel can be turned for one and a half turns. Is there any difference between it and two turns
Rabbit MQ message sending of vertx
Redis distributed lock, lock code logic
如何做一个炫酷的墨水屏电子钟?
Marubeni Baidu applet detailed configuration tutorial, approved.
Design of KTV intelligent dimming system based on MCU
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
Official announcement! The third cloud native programming challenge is officially launched!
How to make a cool ink screen electronic clock?
Exploration of short text analysis in the field of medical and health (II)
Start the remedial work. Print the contents of the array using the pointer
Asp+access campus network goods trading platform
openresty ngx_ Lua variable operation
Avoid material "minefields"! Play with super high conversion rate
Visual studio 2019 set transparent background (fool teaching)
Bert fine tuning skills experiment
Three properties that a good homomorphic encryption should satisfy
Action News
Zabbix