当前位置:网站首页>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;
} 边栏推荐
- uva1169
- LeetCode:1380. Lucky number in matrix -- simple
- ROS知识点——消息过滤器 ( message_filters)
- Helm kubernetes package management tool
- Smart trash can (V) - light up OLED
- 牛客 JS3 分隔符
- 【网络是怎么连接的】第四章 探索接入网和网络运营商
- HBuilderX运行到手机或模拟器提示没有找到设备
- 牛客JS2 文件扩展名
- From collection to output: inventory those powerful knowledge management tools - inventory of excellent note taking software (4)
猜你喜欢

Win10系统使用pip安装juypter notebook过程记录(安装在系统盘以外的盘)

例题 非线性整数规划

Navigateur Chrome pour un accès rapide au stackoverflow

Platform management background and merchant menu resource management: merchant role management design

Solution to the problem that the easycvr kernel of intelligent video analysis platform cannot be started as a service

【網絡是怎樣連接的】第六章 請求到達服務器以及響應給客戶端(完結)

Simple linear programming problem

智能水电表能耗监测云平台

Virtual lab basic experiment tutorial -7 Polarization (2)

Alibaba Tianchi SQL learning notes - Day3
随机推荐
从收集到输出:盘点那些强大的知识管理工具——优秀笔记软件盘点(四)
HDU - 1114 Piggy-Bank(完全背包)
Introduce the scrollintoview() method attribute in detail
Explanation of traceroute command
Use of nexttile function in MATLAB
Migrate your accelerator based SAP commerce cloud storefront to Spartacus
Wechat applet - arrows floating up and down
Platform management background and business menu resource management: business permissions and menu resource management design
JS20 数组扁平化
Introduction to nexus and detailed tutorial of Xiaobai using idea to package and upload to nexus3 private server
IPtables中SNAT、DNAT和MASQUERADE的含义
每日一题——倒置字符串
ROS知识点——ros::NodeHandle n 和 nh(“~“)的区别
每日一题——“水仙花数”
What is agile development process
Ocio V2 reverse LUT
Séparateur JS3 de niuke
ROS知识点——消息过滤器 ( message_filters)
将您的基于 Accelerator 的 SAP Commerce Cloud Storefront 迁移到 Spartacus
[how to connect the network] Chapter 5 explore the server