cf C. Xenia and Weights
http://codeforces.com/contest/339/problem/C
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; int dp[][][];
char str[];
int f[];
int m;
void dfs(int i,int j,int k)
{
if(i==) return ;
dfs(i-,k-j,dp[i][j][k]);
printf("%d ",k);
} int main()
{
scanf("%s",str);
int cnt=;
for(int i=; i<; i++)
{
if(str[i]=='')
{
f[++cnt]=i+;
}
}
scanf("%d",&m);
memset(dp,-,sizeof(dp));
dp[][][]=;
for(int i=; i<=m; i++)
{
for(int j=; j<=; j++)
{
for(int k=; k<=; k++)
{
if(dp[i-][j][k]!=-)
{
for(int c=; c<=cnt; c++)
{
if(f[c]>j&&f[c]!=k)
dp[i][f[c]-j][f[c]]=k;
}
}
}
}
}
for(int i=; i<=; i++)
{
for(int j=; j<=; j++)
{
if(dp[m][i][j]!=-)
{
printf("YES\n");
dfs(m,i,j);
return ;
}
}
}
printf("NO\n");
return ;
}
cf C. Xenia and Weights的更多相关文章
- [codeforces 339]C. Xenia and Weights
[codeforces 339]C. Xenia and Weights 试题描述 Xenia has a set of weights and pan scales. Each weight has ...
- Xenia and Weights(深度优先搜索)
Xenia and Weights time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...
- codeforces 339C Xenia and Weights(dp或暴搜)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Xenia and Weights Xenia has a set of weig ...
- CF #635D Xenia and Colorful Gems 枚举+二分
Xenia and Colorful Gems 题意 给出三个数组,在每个数组中选择一个数字x,y,z,,使得\((x-y)^2+(y-z)^2+(x-z)^2\)最小. 思路 我们假设x<=y ...
- CF A. Xenia and Divisors
题目大意: n(为三的倍数)个数的一个序列(每个数均不大于7),找出a,b,c a能被b整除,b能被c整除,序列中的每个数都被用到. 1 2 3 4 5 6 7 只有 1 2 4 1 2 6 1 3 ...
- cf D. Xenia and Hamming
http://codeforces.com/contest/357/problem/D 题意:给你两个数n和m,表示两个字符串的循环次数,然后给出两个字符串,求出其相同位置字符不同的个数. 先求出两个 ...
- CodeForces 339C Xenia and Weights(暴力求解DFS)
题意:给定 1-10的某几种砝码,给定的每种有无穷多个,然后放 m 个在天平上,要满足,相邻的两次放的砝码不能是同一种,然后是在天平两端轮流放,并且放在哪一个托盘上,那么天平必须是往哪边偏. 析:这个 ...
- 【Codeforces 339C】Xenia and Weights
[链接] 我是链接,点我呀:) [题意] 在天平上放砝码 你要在左边放一下然后到右边放一下 一直重复这样放m次 每次你放在其中一边都要让另外一边的重量比你少 你可以用1~10中的某些砝码 问你要怎样放 ...
- Xenia and Weights(Codeforces Round #197 (Div. 2)+DP)
题目链接 传送门 思路 \(dp[i][j][k]\)表示第\(i\)次操作放\(j\)后与另一堆的重量差为\(k\)是否存在. 代码实现如下 #include <set> #includ ...
随机推荐
- 智能卡安全机制比较系列(三) MPCOS
MPCOS是金普斯早期推出的一款多应用支付芯片卡操作系统,支持ISO7816以及PCOS的数据格式和命令.MPCOS具有两级目录文件结构,即MF下可以有一级DF,每个DF下最多可创建63个EF. MP ...
- VS2015 C#6.0 中的那些新特性(转载)
自动属性初始化 (Initializers for auto-properties) 以前我们是这么写的 为一个默认值加一个后台字段是不是很不爽,现在我们可以这样写 只读属性的初始化(Getter-o ...
- bzoj1148
题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1148 很常见的排序贪心题...... 假设我们得到了一个最优序列,记s[n]=w[1]+w[2 ...
- paip.hadoop的应用研究总结
paip.hadoop的应用研究总结 作者Attilax , EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csdn.net/attil ...
- python学习Processing
# -*- coding: utf-8 -*-__author__ = 'Administrator'import bisect#排序说明:http://en.wikipedia.org/wiki/i ...
- 关于ionic的一些坑(3)
(1)对于页面中的input之类的输入框,取值的时候一般采用的是$scope.model=””的方式来取得input输入框的值,然后进行操作,但实际上在ionic里面是取不到的,取值之前必须先把inp ...
- 【CSS3】横屏引导小动画
演示地址:http://codepen.io/anon/pen/oXbXdX 主要知识点: @media all and (orientation : landscape) { /* 这是匹配横屏的状 ...
- Arcgis API for Android之GPS定位
欢迎大家增加Arcgis API for Android的QQ交流群:337469080 先说说写这篇文章的原因吧,在群内讨论的过程中,有人提到了定位的问题,刚好,自己曾经在做相关工作的时候做过相关的 ...
- EnableDocking
CFrameWnd::EnableDocking void EnableDocking(DWORD dwDockStyle); 參数: dwDockStyle 指定框架窗体的哪一边可作为控件条的停靠点 ...
- asp.net 参数形式写sql
OracleConnection conn = c.GetConnection(); OracleCommand cmd = new OracleCommand(); ...