HLG1067QQ Farm【状压dp】

本文针对QQ农场游戏中的蚊子拍击问题进行算法分析。通过使用状压DP算法解决每秒至少拍击一只蚊子以获取经验值的问题,并考虑了拍击蚊子数量与得分的关系。
QQ Farm
Time Limit: 1000 MSMemory Limit: 65536 K
Total Submit: 33(11 users)Total Accepted: 10(8 users)Rating: Special Judge: No
Description

 

Many boys and girls play the game QQ farm, For example, in this picture we can see xnby Lance and so on. Sometimes there are some mosquitoes in our farm, we use a rectangular-shaped pad to kill them, and our experience will increase by 3 points after killing each mosquito .But now we find that using a square-shaped pad works better. when using the square-shaped pad, if we kill n mosquito at one time, our experience will increase by n×n points. For example, if we kill 4 mosquitoes at one time, our experience will increase by 16 points. A mosquito was killed when it is covered by the pad, but killing them is not so easy, because them are flying all the time. Now we got the radius of the pad and the location of every mosquito in each second, in each second we could use the pad just once, and we must kill at least one mosquito every second. You are asked to write a program to compute how many points we can get at most.

Input

There are multiple test cases.

In each case, The first line contains two integers: N, T, which indicate the number of mosquitoes and the number of seconds.

The second line contains one Real number R, the length of the pad’s side.

The following T lines, each contains N pairs of Real numbers: (X1, Y1), (X2, Y2)…(XT, YT), which indicate the locations of those mosquitoes at the corresponding second.

Those real numbers are rounded to two digits after the decimal point.

The sides of the pad must be parallel to x-axis or Y-axis.

( 0 < N ≤ 10, 0 < T ≤ N, -1000000 ≤ R, Xi, Yi ≤ 1000000 )

Output

The number of points we could get at most.

Sample Input
3 2
2.00
1.00 1.00 2.00 2.00 3.00 3.00
0.00 0.00 2.00 2.00 4.00 4.00
3 1
2.00
1.00 1.00 2.00 2.00 3.00 3.00
Sample Output
5
9
Author
yiyi4321@Footmen

啊啊啊啊啊啊啊啊   这个题卡我两天啊    啊啊啊啊啊啊啊啊啊啊

大意:有n个蚊子  t个时期  告诉你每个时期每个蚊子的坐标

有一个正方形的苍蝇拍  每个时期最少拍一个蚊子  point+拍死蚊子个数的额平方

问最后最多的point

 

分析:

由于n<= 10所以状压

dp[i][j] 代表i时期状态为j最大的point

dp[i][j] = max(dp[i - 1][k] + cnt * cnt)

然后这时候遇到一个问题就是苍蝇拍该如何放的问题

刚开始的时候我是这么处理的

枚举所有的一对点i,j然后求出以这两个点位边缘的正方形有包含哪几个点

然后wa一次

原因是不可能每一次都拍的最大的点的个数  有可能它选择一个少的个数的拍

然后我又想到一个思路就是用一个vector存所有的拍的情况

vector   v[i][j]代表  i时期 最多拍死j个蚊子有哪些团

这时候就能用10*10来枚举所有的状态

然后又wa无数次

之后跟wht讨论中发现了错误

原来每次枚举拍死x个蚊子的时候它可能拍死的不止x个蚊子

例如1011他拍死的肯能是1111但是不会被发现

处理就是枚举一下所有的点看其它点是不是也被收入之中  若没有被收入  那么就是合法的删除状态

a

 

代码:

  1 #include <iostream>
  2 #include <cstdio>
  3 #include <cstring>
  4 #include <vector>
  5 #include <cmath>
  6 using namespace std;
  7 
  8 const int maxn = 11;
  9 const double INF = 1000000000.0;
 10 int dp[maxn][1 << maxn];
 11 vector<int>v[maxn][maxn];
 12 int ok[maxn];
 13 double x[maxn][maxn], y[maxn][maxn];
 14 int t, n;
 15 double r;
 16 int eps(double x) {
 17     if(fabs(x) < 1e-6) {
 18         return 0;
 19     } 
 20     if(x < 0) return -1;
 21     return 1;
 22 }
 23 
 24 void init() {
 25     for(int i = 1; i < maxn; i++) {
 26         for(int j = 1; j < maxn; j++) {
 27             v[i][j].clear();
 28         }
 29     }
 30     int Max = 1 << n;
 31     double nx, ny, mx, my;
 32     for(int i = 1; i <= t; i++) {
 33         for(int j = 0; j < Max; j++) {
 34             int cnt = 0; nx = ny = INF; mx = my = - INF;
 35             for(int k = 1; k <= n; k++) {
 36                 if((j & ( 1 << ( k - 1 ) ) )) {
 37 //                    printf(" j == %d  k == %d   ans = %d\n", j, k, (j & ( 1 << ( k - 1 ) ) ));
 38                     ok[cnt++] = k;
 39                     nx = min(nx, x[i][k]);
 40                     ny = min(ny, y[i][k]);
 41 
 42                     mx = max(mx, x[i][k]);
 43                     my = max(my, y[i][k]);
 44                 }
 45             }
 46             if(cnt && eps(mx - nx - r) <= 0 && eps(my - ny - r) <= 0) {
 47                 int vis[maxn] = { 0 };
 48                 bool flag = true;
 49                 for(int k = 0; k < cnt; k++) {
 50                     vis[ok[k]] = 1;
 51                 }
 52                 for(int l = 1; l <= n; l++) {
 53                     if(!vis[l] && eps(x[i][l] - nx) >= 0 && eps(x[i][l] - mx) <= 0 && eps(y[i][l] - ny) >= 0 && eps(y[i][l] - my) <= 0) {
 54                         flag = false;
 55                         break;
 56                     }
 57                 }
 58                 if(flag) 
 59                     for(int k = 0; k < cnt; k++) {
 60                         v[i][cnt].push_back(ok[k]);
 61                     }
 62             }
 63         }
 64     }
 65 //    for(int i = 1; i <= t; i++) {
 66 //        for(int j = 1; j <= n; j++) {
 67 //            for(int k = 0; k < v[i][j].size(); k++) {
 68 //                printf("%d %d %d\n", i, j, v[i][j][k]);
 69 //            }
 70 //        }
 71 //    }
 72 //    puts("");
 73 }
 74 
 75 void DP() {
 76     memset(dp, -1, sizeof(dp));
 77     dp[0][0] = 0;
 78     int Max = 1 << n;
 79     for(int i = 1; i <= t; i++) {
 80         for(int j = 0; j < Max; j++) {
 81             if(dp[i - 1][j] != -1) {
 82                 for(int k = 1; k <= n; k++) {
 83                     int vs = v[i][k].size();
 84                     if(vs) {
 85                         int flag = j; int cnt = 0;
 86                         for(int l = 0; l < vs; l++) {
 87                             int id = v[i][k][l];
 88 //                            printf("i == %d  k == %d  ans = %d\n", i, k, v[i][k][l]);
 89                             if((flag & ( 1 << ( id - 1 ) ) ) == 0) {
 90                                 flag |= ( 1 << ( id - 1 ) );
 91                                 cnt ++;
 92                             }
 93                             if((l + 1) % k == 0 && cnt) {
 94                                 dp[i][flag] = max(dp[i][flag], dp[i - 1][j] + cnt * cnt);
 95                                 flag = j;
 96                                 cnt = 0;
 97                             }
 98                         }
 99                     }
100                 }
101             }
102         }
103     }
104 }
105 
106 int ANS() {
107     int ans = 0; int Max = 1 << n;
108     for(int i = 0; i < Max; i++) {
109         ans = max(ans, dp[t][i]);
110     }
111     return ans;
112 }
113 
114 int main() {
115     while(EOF != scanf("%d %d",&n, &t) ) {
116         scanf("%lf",&r);
117         for(int i = 1; i <= t; i++) {
118             for(int j = 1; j <= n; j++) {
119                 scanf("%lf %lf",&x[i][j], &y[i][j]);
120             }
121         }
122         init();
123         DP();
124         printf("%d\n", ANS());
125     }
126     return 0;
127 }
View Code

 

06-16
### HLG 和 SPS 的技术信息及配置方法 HLG(Hybrid Log-Gamma)是一种用于广播的HDR格式,与传统的HDR10不同,它不需要依赖元数据来实现兼容性[^1]。SPS(Sequence Parameter Set)是H.264/AVC或H.265/HEVC编码标准中的重要组成部分,用于描述视频序列的基本参数,例如分辨率、帧率和色彩空间等。 在H.265/HEVC编码中,SPS可以包含与HDR相关的参数,例如色域(BT.2020)、转移特性(HLG EOTF)以及位深等。以下是关于HLG和SPS结合的技术信息及配置方法: #### 1. HLG 在 SPS 中的配置 在HEVC编码中,SPS可以通过VUI(Video Usability Information)部分定义HDR相关信息。对于HLG内容,以下参数需要特别注意: - **colour_primaries**:设置为9,表示BT.2020。 - **transfer_characteristics**:设置为18,表示HLG EOTF[^1]。 - **matrix_coeffs**:设置为9,表示BT.2020非缩矩阵。 以下是一个示例SPS配置代码片段,适用于HLG内容的HEVC编码: ```c // 示例:SPS 配置中的 VUI 参数 vui_parameters_present_flag = 1; colour_primaries = 9; // BT.2020 transfer_characteristics = 18; // HLG EOTF matrix_coeffs = 9; // BT.2020 non-constant ``` #### 2. 编码工具中的HLG支持 主流的视频编码工具如FFmpeg支持HLG的编码和解码。以下是使用FFmpeg生成带有HLG特性的HEVC文件的命令示例: ```bash ffmpeg -i input.mp4 -vf "zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709:o=tv,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p" -c:v libx265 -x265-params "colorprim=bt2020:transfer=smpte2084:colormatrix=bt2020nc" -crf 24 output.hevc ``` 上述命令中,`colorprim=bt2020`、`transfer=smpte2084`和`colormatrix=bt2020nc`分别对应HLG的色彩空间和传输特性。 #### 3. HLG 的显示兼容性 由于HLG不依赖元数据,因此它可以无缝地在SDR和HDR显示器上播放。然而,在SDR显示器上播放HLG内容时,可能会出现色调变化的问题,尤其是在饱和颜色的明亮区域[^1]。这种现象可以通过调整编码参数或使用更高级的色调映射算法来缓解。 #### 4. 技术文档推荐 关于HLG和SPS的详细技术文档,可以参考以下资源: - ITU-R BT.2100:定义了HLG和PQ两种EOTF的标准。 - ISO/IEC 23008-2:HEVC标准文档,详细描述了SPS和VUI的结构。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值