当前位置:网站首页>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;
}
边栏推荐
- Data driving of appium framework for mobile terminal automated testing
- Cocos Creator 2. X automatic packaging (build + compile)
- QT串口ui设计和解决显示中文乱码
- Learn from me about the enterprise flutter project: simplified framework demo reference
- 8 cool visual charts to quickly write the visual analysis report that the boss likes to see
- One article takes you to understand machine learning
- The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)
- Caching mechanism of Hibernate / session level caching mechanism
- Eleven requirements for test management post
- Low level version of drawing interface (explain each step in detail)
猜你喜欢

The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)
![[solved] access denied for user 'root' @ 'localhost' (using password: yes)](/img/71/1ff8ed1d773da99054310f96dca3f8.jpg)
[solved] access denied for user 'root' @ 'localhost' (using password: yes)

Record a jar package conflict resolution process

关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM

First knowledge of database

Asemi rectifier bridge umb10f parameters, umb10f specifications, umb10f package

Deep understanding of grouping sets statements in SQL

2022 love analysis · panoramic report of digital manufacturers of state-owned enterprises
![[web security] - [SQL injection] - error detection injection](/img/18/5c511871dab0e5c684b6b4c081c061.jpg)
[web security] - [SQL injection] - error detection injection

【声明】关于检索SogK1997而找到诸多网页爬虫结果这件事
随机推荐
14 topics for performance interviews between superiors and subordinates (4)
[redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)
Top k questions of interview
Low level version of drawing interface (explain each step in detail)
Thinking about telecommuting under the background of normalization of epidemic | community essay solicitation
斑馬識別成狗,AI犯錯的原因被斯坦福找到了
TCP拥塞控制详解 | 3. 设计空间
Construction practice camp - graduation summary of phase 6
Explore Cassandra's decentralized distributed architecture
First!! Is lancet hungry? Official documents
Is it safe to open a stock account by mobile registration? Does it need money to open an account
Mongodb installation and basic operation
Extraction of the same pointcut
面试之 top k问题
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (II)
Cocos Creator 2.x 自动打包(构建 + 编译)
2022爱分析· 国央企数字化厂商全景报告
在ntpdate同步时间的时候出现“the NTP socket is in use, exiting”
Pyinstaller is not an internal or external command, nor is it a runnable program or batch file
From the 18th line to the first line, the new story of the network security industry