当前位置:网站首页>Atcoder beginer contest 237 VP supplement
Atcoder beginer contest 237 VP supplement
2022-07-02 17:42:00 【sophilex】
Carelessness :
Given an undirected graph , The edge right between two points :
The edge weight from the higher point to the lower point is equal to the height difference
The edge weight from the lower point to the higher point is equal to negative twice the height difference
seek : Max in graph dis value
Ideas :
Just build the edge according to the meaning of the topic ;
But it has negative power , So in general dij no way .
After the game, we strengthened the data , So I ran away spfa,T rotten ...( But I think there is a buddy who really uses spfa Rushed over ...【 collapse 】)
The idea of the official solution is dij
consider “ potential ” Thought ( most ):
Preprocess the data , The edge weight from high to low is equal to 0, The distance from low point to high point is equal to the height difference (>=0)
Then it's all non negative side .
Run away dij After that, just restore the data back ,dis[i]=h[i]-h[1]+dist[i]
code:
Besides,
Carelessness :
Find the length of n, Each element is not greater than m Sequence , How many kinds of meet the following conditions :
The length of the longest ascending subsequence is exactly 3.
Ideas :
m Very small , Only 10, It's easy to think of violent enumeration for so long +dp
Might as well set i Represents the length of the current enumerated sequence ,k1 Indicates that the current sequence length is 1 Of LIS The minimum value of the last element of ,k2 Indicates that the current sequence length is 2 Of LIS The minimum value of the last element of ,k3 It means that the current sequence length is 3 Of LIS The minimum value of the last element of
that dp[i][k1][k2][k3] The number of schemes representing the corresponding situation .
Then enumerate one more at a time x, Yes x The size of can be classified and discussed .
See details code:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll N=1005;
const ll mod=998244353;
ll dp[N][12][12][12];
ll n,m;
int main()
{
cin>>n>>m;
dp[0][m+1][m+1][m+1]=1;
for(int i=1;i<=n;++i)
{
for(int k1=1;k1<=m+1;++k1)
{
for(int k2=1;k2<=m+1;++k2)
{
for(int k3=1;k3<=m+1;++k3)
{
for(int x=1;x<=m;++x)
{
if(x<=k1) dp[i][x][k2][k3]=(dp[i-1][k1][k2][k3]+dp[i][x][k2][k3])%mod;
else if(x<=k2) dp[i][k1][x][k3]=(dp[i-1][k1][k2][k3]+dp[i][k1][x][k3])%mod;
else if(x<=k3) dp[i][k1][k2][x]=(dp[i-1][k1][k2][k3]+dp[i][k1][k2][x])%mod;
}
}
}
}
}
ll ans=0;
for(int k1=1;k1<=m;++k1)
{
for(int k2=1;k2<=m;++k2)
{
for(int k3=1;k3<=m;++k3)
{
// cout<<dp[n][k1][k2][k3];
ans=(ans+dp[n][k1][k2][k3])%mod;
}
}
}
cout<<ans<<endl;
return 0;
}
边栏推荐
- 线性规划例题 投资的收益与风险
- LeetCode:1380. Lucky number in matrix -- simple
- si446使用记录(二):使用WDS3生成头文件
- Eye of depth (II) -- matrix and its basic operations
- Migrate your accelerator based SAP commerce cloud storefront to Spartacus
- Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)
- Introduction to nexus and detailed tutorial of Xiaobai using idea to package and upload to nexus3 private server
- chrome瀏覽器快速訪問stackoverflow
- 微信小程序 —— 上下浮动的箭头
- Making tutorial of chicken feet with pickled peppers
猜你喜欢
随机推荐
POJ - 1458 Common Subsequence(最长公共子序列)
CEPH principle
从收集到输出:盘点那些强大的知识管理工具——优秀笔记软件盘点(四)
HBuilderX运行到手机或模拟器提示没有找到设备
VScode知识点——常见报错
JDBC
Chapter 15 string localization and message Dictionary (1)
Introduce the scrollintoview() method attribute in detail
嵌入式开发板 ~ 说明
ROS知识点——ros::NodeHandle n 和 nh(“~“)的区别
SAP commerce cloud storefront framework selection: accelerator or Spartacus?
visibilitychange – 指定标签页可见时,刷新页面数据
泡椒凤爪制作教程
Dstat use [easy to understand]
Microservice architecture practice: Construction of highly available distributed file system fastdfs architecture
Example nonlinear integer programming
Configure lamp+supervisor
Nexus简介及小白使用IDEA打包上传到Nexus3私服详细教程
Microservice architecture practice: Construction of scalable distributed database cluster
每日一题——倒置字符串