当前位置:网站首页>POJ - 2955 brackets interval DP
POJ - 2955 brackets interval DP
2022-04-23 06:21:00 【Bzdhxs_ nt】
Ideas
Classical interval d p dp dp The topic of transfer mode has been given
consider d p [ i ] [ j ] dp[i][j] dp[i][j] It means that [ i , j ] [i,j] [i,j] The number of bracket pairs that can be matched in the interval
State shift
f [ i ] [ j ] = f [ i + 1 ] [ j − 1 ] + c h e c k ( i , j ) ; f[i][j] = f[i+1][j-1] + check(i,j); f[i][j]=f[i+1][j−1]+check(i,j);
f [ i ] [ j ] = m a x ( f [ i ] [ j ] , f [ i ] [ k ] + f [ k + 1 ] [ j ] ) ; f[i][j] = max(f[i][j],f[i][k]+f[k+1][j]); f[i][j]=max(f[i][j],f[i][k]+f[k+1][j]);
Code
int f[110][110];
string s;
bool chk(int i,int j){
if((s[i] == '[' && s[j] == ']')||(s[i]=='(' && s[j]==')')) return true;
return false;
}
signed main()
{
while(cin >> s){
if(s == "end") break;
mem(f,0);
int le = s.size();
forr(len,2,le){
for(int i = 0;i+len-1<le;i++){
int j = i+len-1;
f[i][j] = f[i+1][j-1]+chk(i,j);
for(int k = i;k<j;k++) f[i][j] = max(f[i][j],f[i][k]+f[k+1][j]);
}
}
cout << f[0][le-1]*2 << endl;
}
return 0;
版权声明
本文为[Bzdhxs_ nt]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210617219258.html
边栏推荐
- Traitement des séquelles du flux de Tensor - exemple simple d'enregistrement de torche. Utils. Données. Dataset. Problème de dimension de l'image lors de la réécriture de l'ensemble de données
- 图像恢复论文简记——Uformer: A General U-Shaped Transformer for Image Restoration
- List segmentation best practices
- Fundamentals of digital image processing (Gonzalez) I
- Collections multiple parameter sorting
- PyTorch笔记——通过搭建ResNet熟悉网络搭建方式(完整代码)
- Implementation of displaying database pictures to browser tables based on thymeleaf
- Pytorch introduction notes - use a simple example to observe the output size of each layer of forward propagation
- EditorConfig
- Common sense of thread pool
猜你喜欢

A general U-shaped transformer for image restoration

Implementation of displaying database pictures to browser tables based on thymeleaf

A sharp tool to improve work efficiency

Preparedstatement prevents SQL injection

线性代数第二章-矩阵及其运算
![Paper on Image Restoration - [red net, nips16] image restoration using very deep revolutionary encoder decoder networks wi](/img/1b/4eea05e2634780f45b44273d2764e3.png)
Paper on Image Restoration - [red net, nips16] image restoration using very deep revolutionary encoder decoder networks wi

Linear algebra Chapter 2 - matrices and their operations

RPC must know and know

On traversal of binary tree

Fundamentals of digital image processing (Gonzalez) II: gray transformation and spatial filtering
随机推荐
去噪论文——[Noise2Void,CVPR19]Noise2Void-Learning Denoising from Single Noisy Images
Denoising paper - [noise2void, cvpr19] noise2void learning denoising from single noise images
Kibana search syntax
SQL injection
In depth source code analysis servlet first program
The problem that the page will refresh automatically after clicking the submit button on the form is solved
Reading of denoising paper - [ridnet, iccv19] real image denoising with feature attention
PyTorch笔记——通过搭建ResNet熟悉网络搭建方式(完整代码)
Optional best practices
What is the difference between the basic feasible solution and the basic feasible solution in linear programming?
编程记录——图片旋转函数scipy.ndimage.rotate()的简单使用和效果观察
Stability building best practices
The user name and password of users in the domain accessing the samba server outside the domain are wrong
Techniques et principes de détection
PHP processing JSON_ Decode() parses JSON stringify
Protected (members modified by protected are visible to this package and its subclasses)
CONDA virtual environment management (create, delete, clone, rename, export and import)
container
数字图像处理基础(冈萨雷斯)一
11.a==b?