当前位置:网站首页>Acwing game 58
Acwing game 58
2022-07-03 16:28:00 【leimingzeOuO】
AcWing 4488. seek 1
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
#define x first
#define y second
#define LL long long
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
LL Mod(LL a,LL mod){
return (a%mod+mod)%mod;}
LL lowbit(LL x){
return x&-x;}// Its lowest 1 And behind it 0 The value of composition
LL qmi(LL a,LL b,LL mod) {
LL ans = 1; while(b){
if(b & 1) ans = ans * (a % mod) % mod; a = a % mod * (a % mod) % mod; b >>= 1;} return ans; }
int _;
int n;
void solve()
{
cin>>n;
bool f=false;
for(int i=0;i<n;i++)
{
int x;
cin>>x;
if(x==1)
{
f=true;
cout<<"YES"<<endl;
break;
}
}
if(!f)cout<<"NO"<<endl;
}
signed main()
{
io;
//cin>>_;
//while(_--)
solve();
return 0;
}
AcWing 4489. The longest subsequence
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
#define x first
#define y second
#define LL long long
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
LL Mod(LL a,LL mod){
return (a%mod+mod)%mod;}
LL lowbit(LL x){
return x&-x;}// Its lowest 1 And behind it 0 The value of composition
LL qmi(LL a,LL b,LL mod) {
LL ans = 1; while(b){
if(b & 1) ans = ans * (a % mod) % mod; a = a % mod * (a % mod) % mod; b >>= 1;} return ans; }
int _;
int n;
const int N=2e5+10;
int a[N];
int dp[N];
void solve()
{
cin>>n;
for(int i=1;i<=n;i++)cin>>a[i];
int maxv=1;
for(int i=1;i<=n;i++)dp[i]=1;
for(int i=2;i<=n;i++)
{
if(a[i]<=a[i-1]*2)dp[i]=dp[i-1]+1;
maxv=max(maxv,dp[i]);
}
cout<<maxv<<endl;
}
signed main()
{
io;
//cin>>_;
//while(_--)
solve();
return 0;
}
AcWing 4490. dyeing
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
#define x first
#define y second
#define LL long long
#define int LL
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define PII pair<int,int>
#define ll_INF 0x7f7f7f7f7f7f7f7f
#define INF 0x3f3f3f3f
#define debug(x) cerr << #x << ": " << x << endl
#define io ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
LL Mod(LL a,LL mod){
return (a%mod+mod)%mod;}
LL lowbit(LL x){
return x&-x;}// Its lowest 1 And behind it 0 The value of composition
LL qmi(LL a,LL b,LL mod) {
LL ans = 1; while(b){
if(b & 1) ans = ans * (a % mod) % mod; a = a % mod * (a % mod) % mod; b >>= 1;} return ans; }
int _;
int n;
const int N=1e4+10;
int h[N],e[N],ne[N],idx;
int c[N];
void add(int a,int b)
{
e[idx]=b,ne[idx]=h[a],h[a]=idx++;
}
int dfs(int u,int color)
{
int res=0;
if(c[u]!=color)
{
res++;
color=c[u];
}
for(int i=h[u];~i;i=ne[i])
{
int j=e[i];
res+=dfs(j,color);
}
return res;
}
void solve()
{
cin>>n;
memset(h,-1,sizeof h);
for(int i=2;i<=n;i++)
{
int x;
cin>>x;
add(x,i);
}
for(int i=1;i<=n;i++)cin>>c[i];
cout<<dfs(1,0)<<endl;
}
signed main()
{
io;
//cin>>_;
//while(_--)
solve();
return 0;
}
边栏推荐
- Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (I)
- 近视:摘镜or配镜?这些问题必须先了解清楚
- [redis foundation] understand redis master-slave architecture, sentinel mode and cluster together (Demo detailed explanation)
- 于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
- [combinatorics] combinatorial identities (sum of variable terms 3 combinatorial identities | sum of variable terms 4 combinatorial identities | binomial theorem + derivation to prove combinatorial ide
- Advanced Mathematics (Seventh Edition) Tongji University exercises 2-1 personal solutions
- 0214-27100 a day with little fluctuation
- Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package
- Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
- Mysql 将逗号隔开的属性字段数据由列转行
猜你喜欢

Threejs Part 2: vertex concept, geometry structure

面试官:JVM如何分配和回收堆外内存

Cocos Creator 2. X automatic packaging (build + compile)

Embedded development: seven reasons to avoid open source software

Learn from me about the enterprise flutter project: simplified framework demo reference

Record a jar package conflict resolution process

记一次jar包冲突解决过程

Google Earth engine (GEE) - daymet v4: daily surface weather data set (1000m resolution) including data acquisition methods for each day

Mongodb installation and basic operation

消息队列消息丢失和消息重复发送的处理策略
随机推荐
【LeetCode】94. Middle order traversal of binary tree
How to initialize views when loading through storyboards- How is view initialized when loaded via a storyboard?
TCP擁塞控制詳解 | 3. 設計空間
Getting started with Message Oriented Middleware
于文文、胡夏等明星带你玩转派对 皮皮APP点燃你的夏日
Client does not support authentication protocol requested by server; consider upgrading MySQL client
SVN使用规范
[redis foundation] understand redis master-slave architecture, sentinel mode and cluster together (Demo detailed explanation)
How to set up SVN server on this machine
How can technology managers quickly improve leadership?
EditText request focus - EditText request focus
[web security] - [SQL injection] - error detection injection
【声明】关于检索SogK1997而找到诸多网页爬虫结果这件事
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
[proteus simulation] 8 × 8LED dot matrix screen imitates elevator digital scrolling display
Golang 装饰器模式以及在NSQ中的使用
Colab works with Google cloud disk
"The NTP socket is in use, exiting" appears when ntpdate synchronizes the time
Mb10m-asemi rectifier bridge mb10m
Cocos Creator 2.x 自动打包(构建 + 编译)