当前位置:网站首页>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;
}
边栏推荐
- Client does not support authentication protocol requested by server; consider upgrading MySQL client
- Multithread 02 thread join
- Learn from me about the enterprise flutter project: simplified framework demo reference
- How to use AAB to APK and APK to AAB of Google play apps on the shelves
- Leetcode binary search tree
- June to - -------
- 切入点表达式
- 面试之 top k问题
- Unreal_ Datatable implements ID self increment and sets rowname
- Cocos Creator 2.x 自动打包(构建 + 编译)
猜你喜欢
跟我学企业级flutter项目:简化框架demo参考
QT serial port UI design and solution to display Chinese garbled code
Colab works with Google cloud disk
How to thicken the brush in the graphical interface
Slam learning notes - build a complete gazebo multi machine simulation slam from scratch (III)
Famous blackmail software stops operation and releases decryption keys. Most hospital IOT devices have security vulnerabilities | global network security hotspot on February 14
关于视觉SLAM的最先进技术的调查-A survey of state-of-the-art on visual SLAM
[redis foundation] understand redis persistence mechanism together (rdb+aof graphic explanation)
[solved] access denied for user 'root' @ 'localhost' (using password: yes)
TCP拥塞控制详解 | 3. 设计空间
随机推荐
[combinatorics] combinatorial identity (sum of variable upper terms 1 combinatorial identity | summary of three combinatorial identity proof methods | proof of sum of variable upper terms 1 combinator
SDNU_ ACM_ ICPC_ 2022_ Winter_ Practice_ 4th [individual]
Develop team OKR in the way of "crowdfunding"
One article takes you to understand machine learning
Explore Cassandra's decentralized distributed architecture
[statement] about searching sogk1997 and finding many web crawler results
Is it safe to open an account with flush?
pyinstaller不是内部或外部命令,也不是可运行的程序 或批处理文件
Learn from me about the enterprise flutter project: simplified framework demo reference
PHP CI(CodeIgniter)log级别设置
From the 18th line to the first line, the new story of the network security industry
Pychart error updating package list: connect timed out
切入点表达式
Is it safe to open a stock account by mobile registration? Does it need money to open an account
"The NTP socket is in use, exiting" appears when ntpdate synchronizes the time
Unreal_ Datatable implements ID self increment and sets rowname
深入理解 SQL 中的 Grouping Sets 语句
QT串口ui设计和解决显示中文乱码
Visual SLAM algorithms: a survey from 2010 to 2016
Top k questions of interview