当前位置:网站首页>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;
}
边栏推荐
- 2022爱分析· 国央企数字化厂商全景报告
- 《天天数学》连载56:二月二十五日
- Visual SLAM algorithms: a survey from 2010 to 2016
- 用同花顺炒股开户安全吗?
- Embedded development: seven reasons to avoid open source software
- "Everyday Mathematics" serial 56: February 25
- Batch files: list all files in a directory with relative paths - batch files: list all files in a directory with relative paths
- 在ntpdate同步时间的时候出现“the NTP socket is in use, exiting”
- nifi从入门到实战(保姆级教程)——flow
- [web security] - [SQL injection] - error detection injection
猜你喜欢

0214-27100 a day with little fluctuation

Deep understanding of grouping sets statements in SQL
![[web security] - [SQL injection] - error detection injection](/img/18/5c511871dab0e5c684b6b4c081c061.jpg)
[web security] - [SQL injection] - error detection injection

Remote file contains actual operation

(补)双指针专题

Stm32f103c8t6 firmware library lighting

Multithread 02 thread join

How to use AAB to APK and APK to AAB of Google play apps on the shelves

近视:摘镜or配镜?这些问题必须先了解清楚

深入理解 SQL 中的 Grouping Sets 语句
随机推荐
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
Google Earth engine (GEE) - daymet v4: daily surface weather data set (1000m resolution) including data acquisition methods for each day
Expression of request header in different countries and languages
TCP擁塞控制詳解 | 3. 設計空間
Is it safe to open a stock account by mobile registration? Does it need money to open an account
架构实战营 - 第 6 期 毕业总结
Mb10m-asemi rectifier bridge mb10m
无心剑中译泰戈尔《漂鸟集(1~10)》
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (4)
Extraction of the same pointcut
8 tips for effective performance evaluation
远程办公之大家一同实现合作编辑资料和开发文档 | 社区征文
[combinatorics] combinatorial identities (sum of variable terms 3 combinatorial identities | sum of variable terms 4 combinatorial identities | binomial theorem + derivation to prove combinatorial ide
Cocos Creator 2. X automatic packaging (build + compile)
Golang anonymous function use
Batch files: list all files in a directory with relative paths - batch files: list all files in a directory with relative paths
The accept attribute of the El upload upload component restricts the file type (detailed explanation of the case)
Interviewer: how does the JVM allocate and recycle off heap memory
Everyone in remote office works together to realize cooperative editing of materials and development of documents | community essay solicitation
线程池执行定时任务