当前位置:网站首页>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;
}
边栏推荐
- Blue bridge - maximum common divisor and minimum common multiple
- Subject 3 how to turn on the high beam diagram? Is the high beam of section 3 up or down
- Abacus mental arithmetic test
- The database and recharge are gone
- The perfect car for successful people: BMW X7! Superior performance, excellent comfort and safety
- Design and implementation of kindergarten management system
- Elk log analysis system
- Avoid material "minefields"! Play with super high conversion rate
- Chinese natural language processing, medical, legal and other public data sets, sorting and sharing
- Pgadmin 4 V6.5 release, PostgreSQL open source graphical management tool
猜你喜欢

Spoon inserts and updates the Oracle database, and some prompts are inserted with errors. Assertion botch: negative time

Grub 2.12 will be released this year to continue to improve boot security
![ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience](/img/22/08617736a8b943bc9c254aac60c8cb.jpg)
ASP. Net core 6 framework unveiling example demonstration [01]: initial programming experience

官宣!第三届云原生编程挑战赛正式启动!

Asynchronous and promise

Go RPC call

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

Design of kindergarten real-time monitoring and control system

问题解决:AttributeError: ‘NoneType‘ object has no attribute ‘append‘

Spark SQL learning bullet 2
随机推荐
Advanced conditional statements of common SQL operations
Bumblebee: build, deliver, and run ebpf programs smoothly like silk
Prometheus monitors the correct posture of redis cluster
ELK日志分析系统
Which common ports should the server open
Character painting, I use characters to draw a Bing Dwen Dwen
tuple and point
Yolov5 model training and detection
Go RPC call
Design and implementation of kindergarten management system
Visual explanation of Newton iteration method
Design and implementation of high availability website architecture
Design and implementation of community hospital information system
[understanding of opportunity -38]: Guiguzi - Chapter 5 flying clamp - warning one: there is a kind of killing called "killing"
【LeetCode】222. The number of nodes of a complete binary tree (2 mistakes)
d3js小记
Naacl 2021 | contrastive learning sweeping text clustering task
CAM Pytorch
Single line function*
Blue bridge - maximum common divisor and minimum common multiple