当前位置:网站首页>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;
}
边栏推荐
- The steering wheel can be turned for one and a half turns. Is there any difference between it and two turns
- Avoid material "minefields"! Play with super high conversion rate
- Hmi-30- [motion mode] the module on the right side of the instrument starts to write
- Pgadmin 4 V6.5 release, PostgreSQL open source graphical management tool
- Subject 3 how to turn on the high beam diagram? Is the high beam of section 3 up or down
- The application and Optimization Practice of redis in vivo push platform is transferred to the end of metadata by
- RichView TRVUnits 图像显示单位
- "C zero foundation introduction hundred knowledge and hundred cases" (72) multi wave entrustment -- Mom shouted for dinner
- 【微服务|SCG】Filters的33种用法
- GFS分布式文件系统
猜你喜欢
Hmi-32- [motion mode] add light panel and basic information column
Open source SPL optimized report application coping endlessly
Yolov5 model training and detection
8. Commodity management - commodity classification
[200 opencv routines] 99 Modified alpha mean filter
Unpool(nn.MaxUnpool2d)
Icu4c 70 source code download and compilation (win10, vs2022)
Spark SQL learning bullet 2
The most powerful new household god card of Bank of communications. Apply to earn 2100 yuan. Hurry up if you haven't applied!
Action News
随机推荐
Yuan universe also "real estate"? Multiple second-hand trading websites block metauniverse keywords
Pytorch register_ Hook (operate on gradient grad)
The most powerful new household god card of Bank of communications. Apply to earn 2100 yuan. Hurry up if you haven't applied!
A tab Sina navigation bar
【LeetCode】106. Construct binary tree from middle order and post order traversal sequence (wrong question 2)
Process scheduling and termination
"C zero foundation introduction hundred knowledge and hundred cases" (72) multi wave entrustment -- Mom shouted for dinner
丸子百度小程序详细配置教程,审核通过。
使用druid連接MySQL數據庫報類型錯誤
[技术发展-26]:新型信息与通信网络的数据安全
Scientific research: are women better than men?
Spoon inserts and updates the Oracle database, and some prompts are inserted with errors. Assertion botch: negative time
Design and practice of kubernetes cluster and application monitoring scheme
Blue bridge - maximum common divisor and minimum common multiple
Chinese natural language processing, medical, legal and other public data sets, sorting and sharing
Moco V2 literature research [self supervised learning]
Subject 3 how to turn on the high beam diagram? Is the high beam of section 3 up or down
Exploration of short text analysis in the field of medical and health (II)
Pytest (4) - test case execution sequence
Visual studio 2019 set transparent background (fool teaching)