当前位置:网站首页>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;
} 边栏推荐
- chrome浏览器快速访问stackoverflow
- Nexus簡介及小白使用IDEA打包上傳到Nexus3私服詳細教程
- Si446 usage record (II): generate header files using wds3
- HBuilderX运行到手机或模拟器提示没有找到设备
- ssb门限_SSB调制「建议收藏」
- AtCoder Beginner Contest 237 VP补题
- visibilitychange – 指定标签页可见时,刷新页面数据
- No such file or directory: ‘/tmp/tmpxxx/tmpxxx.py‘
- JS20 数组扁平化
- Introduction to nexus and detailed tutorial of Xiaobai using idea to package and upload to nexus3 private server
猜你喜欢

Modbus协议通信异常

Map集合详细讲解

The bottom simulation implementation of vector

vector的底层模拟实现

Daily question - inverted string

每日一题——倒置字符串

Chapter 15 string localization and message Dictionary (1)

easyswoole3.2重启不成功
![[web technology] 1233 seconds understand web component](/img/42/c98d8112dc4ece0a92dda97647be5c.jpg)
[web technology] 1233 seconds understand web component
![[comment le réseau se connecte] chapitre 6: demande d'accès au serveur et réponse au client (terminé)](/img/ef/1ac272dbd0e5c4d08a8f01f61d334d.png)
[comment le réseau se connecte] chapitre 6: demande d'accès au serveur et réponse au client (terminé)
随机推荐
What is agile development process
线性规划例题 投资的收益与风险
Chrome browser quick access stackoverflow
class和getClass()的区别
选择 SAP Spartacus 作为 SAP Commerce Cloud Storefront 实现框架的五个理由
[非线性控制理论]7_High gain and High Frequency
每日一题——倒置字符串
What are the green field and brown field models in software development - green field development and brown field development
IDEA2021.1 安装教程
阿里天池SQL学习笔记——DAY3
Séparateur JS3 de niuke
[web technology] 1233 seconds understand web component
chmod命令原理及用法详解[通俗易懂]
executescalar mysql_ ExecuteScalar()
RK1126平台项目总结
Vscode knowledge points - Common Errors
2022 interview questions
阿里云子账户 - 权限策略 - 授权给某个账户某个 OSS Bucket 的完全控制权限
Win10 system uses pip to install juypter notebook process record (installed on a disk other than the system disk)
Navigateur Chrome pour un accès rapide au stackoverflow