SP15637 GNYR04H - Mr Youngs Picture Permutations 解析

题目链接

分析题目性质

大意就是给 \(k\) 排然后每个数列单调,每个横列单调,求满足这样排列的方案数。

我们发现:与其为每个位置分配某个学生不如考虑将每个学生分给某个位置

思路

根据以上,不妨设:\(f_{a_1,a_2,a_3,a_4,a_5}\) 分别代表第 \(i\) 排现在人数为 \(a_i\) 的方案数。

那么应该满足以下条件:

  • \(a_i < N_i\)
  • \(i=1\) 或者 \(a_{i-1}<a_i\)

转移是简单的。

需要注意的是数组。

#include <iostream>
#include <cstdio>
#include <stdlib.h>
#include <algorithm>
#include <cstring>
#include <vector>
#define int long long
using namespace std;
int k,len[35];
signed main(){
for (;~scanf("%lld",&k);) {
if (k == 0) break;
for (int i = 0;i <= 5;i ++) len[i] = 0;
for (int i = 1;i <= k;i ++) scanf("%lld",&len[i]);
vector<vector<vector<vector<vector<int>>>>> f(
len[1] + 1,
vector<vector<vector<vector<int>>>>(
len[2] + 1,
vector<vector<vector<int>>>(
len[3] + 1,
vector<vector<int>>(
len[4] + 1,
vector<int>(
len[5] + 1,
0
)
)
)
)
);
f[0][0][0][0][0] = 1;
for (int a1 = 0;a1 <= len[1];a1 ++)
for (int a2 = 0;a2 <= len[2];a2 ++)
for (int a3 = 0;a3 <= len[3];a3 ++)
for (int a4 = 0;a4 <= len[4];a4 ++)
for (int a5 = 0;a5 <= len[5];a5 ++) {
if (a1 < len[1]) f[a1 + 1][a2][a3][a4][a5] += f[a1][a2][a3][a4][a5];
if (a2 < len[2] && a2 < a1) f[a1][a2 + 1][a3][a4][a5] += f[a1][a2][a3][a4][a5];
if (a3 < len[3] && a3 < a2) f[a1][a2][a3 + 1][a4][a5] += f[a1][a2][a3][a4][a5];
if (a4 < len[4] && a4 < a3) f[a1][a2][a3][a4 + 1][a5] += f[a1][a2][a3][a4][a5];
if (a5 < len[5] && a5 < a4) f[a1][a2][a3][a4][a5 + 1] += f[a1][a2][a3][a4][a5];
}
printf("%lld\n",f[len[1]][len[2]][len[3]][len[4]][len[5]]);
}
return 0;
}

SP15637 GNYR04H - Mr Youngs Picture Permutations 解析的更多相关文章

  1. SP15637 GNYR04H - Mr Youngs Picture Permutations[DP]

    题目来源:POJ:http://poj.org/problem?id=2279 SPOJ:https://www.spoj.com/problems/GNYR04H/ 题意翻译 题目描述 杨先生希望为 ...

  2. $SP15637\ GNYR04H\ -\ Mr\ Youngs\ Picture\ Permutations$

    传送门 Description 杨先生希望为他的班级拍照.学生将排成一行,每行不超过后面的行,并且行的左端对齐.例如,可以安排12名学生排列(从后到前)5,3,3和1名学生. X X X X X X ...

  3. SP15637 Mr Youngs Picture Permutations 高维动态规划

    问题描述 LG-SP 题解 发现\(n,k\)都非常小,尤其是\(k,k\le 5\),于是直接开\(5\)维进行\(\mathrm{DP}\) 用记忆化搜索实现. \(\mathrm{Code}\) ...

  4. bzoj 2483: Pku2279 Mr. Young's Picture Permutations -- 钩子公式

    2483: Pku2279 Mr. Young's Picture Permutations Time Limit: 1 Sec  Memory Limit: 128 MB Description   ...

  5. POJ2279 Mr Young's Picture Permutations

    POJ2279 Mr Young's Picture Permutations 描述: 有N个学生合影,站成左对齐的k排,每行分别有N1,N2…NK个人,第一排站最后,第k排站之前.学生身高依次是1… ...

  6. 【题解】POJ2279 Mr.Young′s Picture Permutations dp

    [题解]POJ2279 Mr.Young′s Picture Permutations dp 钦定从小往大放,然后直接dp. \(dp(t1,t2,t3,t4,t5)\)代表每一行多少人,判断边界就能 ...

  7. 轮廓线DP:poj 2279 Mr. Young's Picture Permutations

    poj 2279 Mr. Young's Picture Permutations \(solution:\) 首先摘取一些关键词:(每行不超过它后面的行)(每排学生安排高度从左到右减少)(学生的高度 ...

  8. Mr. Young's Picture Permutations

    Mr. Young's Picture Permutations 给出一个有k列的网格图,以及每列图形的高度\(n_i\),下端对齐,保证高度递减,设有n个网格,询问向其中填1~n保证每行每列单调递增 ...

  9. 【杨氏矩阵+勾长公式】POJ 2279 Mr. Young's Picture Permutations

    Description Mr. Young wishes to take a picture of his class. The students will stand in rows with ea ...

  10. poj2279——Mr. Young's Picture Permutations

    Description Mr. Young wishes to take a picture of his class. The students will stand in rows with ea ...

随机推荐

  1. Windows设置本地DNS域名解析hosts文件配置--九五小庞

    DNSDomain Name System(域名系统):为了加快定位IP地址的速度, 将域名映射进行层层缓存的系统. 目的:互联网通过IP(10.223.146.45)定位浏览器建立连接,但是我们不易 ...

  2. 圆刚C725B金星标清采集卡

    C725标清采集卡是一张支持AV端子.S端子以及立体声输入的PCIe卡,可将PAL.NTSC和SECAM等模拟格式影像数字化.采集并另存为无压缩的AVI格式档案.C725标清采集卡随附的软件开发工具包 ...

  3. 进阶篇:2.1)认识到DFMA的作用

    本章目的:只有认识到DFMA对产品设计的提升作用,才能有动力去做它. 1. DFMA是个累活 DFMA是一件非常繁重劳累的活,和DFMEA是一回事.一个产品的DFMA的表格叠加起来可以有厚厚一叠,以后 ...

  4. win11专业版多桌面如何快速切换的问题

    有雨林木风系统的小伙伴使用win11专业版系统时,发现可以创建多个桌面来一起来工作办公,而且每个桌面都是独立的,使用起来很是方便,但是也有很多小伙伴不知道如何快速切换多个桌面,那么win11系统多个桌 ...

  5. CF2077C Binary Subsequence Value Sum 题解

    前言: (虚假的想象学竞赛,实际的数学竞赛) 题意: 给出一个长度为 \(n\) 的二进制序列,我们对于每一个分割点(可以看做在元素与元素之间),其贡献为分割点右边的 \(cnt_1 - cnt_0\ ...

  6. Program-List of 32th

    name function from memo date a01-oeis02.py oeis解析 OEIS 爬虫  OEIS format  书栈网文档 简洁,涉及python3.13的urllib ...

  7. rp 不守恒定律

    kid sama,终究还是,有缘无份. 我一个普普通通高中学生,上午勤勤恳恳在图书馆写了15pages物理,下午老老实实看了名柯首映,礼礼貌貌收了朋友的礼物,如此圆满一日,为何总要峰回路转,将我一箱礼 ...

  8. [题解]P3966 [TJOI2013] 单词

    P3966 [TJOI2013] 单词 对所有模式串建立AC自动机. 用\(p[i]\)来表示经过节点\(i\)的字符串个数. 那么节点\(u\)的答案就是fail树上,以\(u\)为根的子树的\(p ...

  9. .net 8项目通过Autofac获取程序集服务并注册

    首先新建一个AutofacModuleRegister类并继承Autofac.Module. public class AutofacModuleRegister : Autofac.Module { ...

  10. javascript模块 (Module) 简介

    https://blog.csdn.net/chehec2010/article/details/119804381 随着ES6的出现,js模块已经成为正式的标准了.曾经为了解决js模块问题而发展起来 ...