当前位置:网站首页>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;
}
边栏推荐
- Advanced conditional statements of common SQL operations
- Advanced learning of MySQL -- Application -- Introduction
- Privatization lightweight continuous integration deployment scheme -- 01 environment configuration (Part 1)
- spoon插入更新oracle数据库,插了一部分提示报错Assertion botch: negative time
- Video display and hiding of imitation tudou.com
- A tab Sina navigation bar
- Structure of ViewModel
- Chinese natural language processing, medical, legal and other public data sets, sorting and sharing
- Learn game model 3D characters, come out to find a job?
- The steering wheel can be turned for one and a half turns. Is there any difference between it and two turns
猜你喜欢
Tucson will lose more than $400million in the next year
[200 opencv routines] 99 Modified alpha mean filter
Unpool(nn.MaxUnpool2d)
A label colorful navigation bar
Application and Optimization Practice of redis in vivo push platform
Problem solving: attributeerror: 'nonetype' object has no attribute 'append‘
Can you really learn 3DMAX modeling by self-study?
Yuan universe also "real estate"? Multiple second-hand trading websites block metauniverse keywords
问题解决:AttributeError: ‘NoneType‘ object has no attribute ‘append‘
Character painting, I use characters to draw a Bing Dwen Dwen
随机推荐
Spark SQL learning bullet 2
Avoid material "minefields"! Play with super high conversion rate
[technology development-26]: data security of new information and communication networks
Process scheduling and termination
Traditional chips and AI chips
Write a thread pool by hand, and take you to learn the implementation principle of ThreadPoolExecutor thread pool
【LeetCode】98. Verify the binary search tree (2 brushes of wrong questions)
Good documentation
Talk about the things that must be paid attention to when interviewing programmers
Design and implementation of campus epidemic prevention and control system based on SSM
Openresty ngx Lua Execution stage
openresty ngx_ Lua variable operation
Use the difference between "Chmod a + X" and "Chmod 755" [closed] - difference between using "Chmod a + X" and "Chmod 755" [closed]
数据库和充值都没有了
问题解决:AttributeError: ‘NoneType‘ object has no attribute ‘append‘
[understanding of opportunity -38]: Guiguzi - Chapter 5 flying clamp - warning one: there is a kind of killing called "killing"
低度酒赛道进入洗牌期,新品牌如何破局三大难题?
A label colorful navigation bar
Chinese natural language processing, medical, legal and other public data sets, sorting and sharing
Blue bridge - maximum common divisor and minimum common multiple