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的更多相关文章

  1. [codeforces 339]C. Xenia and Weights

    [codeforces 339]C. Xenia and Weights 试题描述 Xenia has a set of weights and pan scales. Each weight has ...

  2. Xenia and Weights(深度优先搜索)

    Xenia and Weights time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  3. codeforces 339C Xenia and Weights(dp或暴搜)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Xenia and Weights Xenia has a set of weig ...

  4. CF #635D Xenia and Colorful Gems 枚举+二分

    Xenia and Colorful Gems 题意 给出三个数组,在每个数组中选择一个数字x,y,z,,使得\((x-y)^2+(y-z)^2+(x-z)^2\)最小. 思路 我们假设x<=y ...

  5. 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 ...

  6. cf D. Xenia and Hamming

    http://codeforces.com/contest/357/problem/D 题意:给你两个数n和m,表示两个字符串的循环次数,然后给出两个字符串,求出其相同位置字符不同的个数. 先求出两个 ...

  7. CodeForces 339C Xenia and Weights(暴力求解DFS)

    题意:给定 1-10的某几种砝码,给定的每种有无穷多个,然后放 m 个在天平上,要满足,相邻的两次放的砝码不能是同一种,然后是在天平两端轮流放,并且放在哪一个托盘上,那么天平必须是往哪边偏. 析:这个 ...

  8. 【Codeforces 339C】Xenia and Weights

    [链接] 我是链接,点我呀:) [题意] 在天平上放砝码 你要在左边放一下然后到右边放一下 一直重复这样放m次 每次你放在其中一边都要让另外一边的重量比你少 你可以用1~10中的某些砝码 问你要怎样放 ...

  9. Xenia and Weights(Codeforces Round #197 (Div. 2)+DP)

    题目链接 传送门 思路 \(dp[i][j][k]\)表示第\(i\)次操作放\(j\)后与另一堆的重量差为\(k\)是否存在. 代码实现如下 #include <set> #includ ...

随机推荐

  1. Linux企业级项目实践之网络爬虫(10)——处理HTTP状态码

    HTTP状态码(HTTP Status Code)是用以表示网页服务器HTTP响应状态的3位数字代码.所有状态码的第一个数字代表了响应的五种状态之一.他们分别是:消息(1字头)成功(2字头)这一类型的 ...

  2. Joomla 3.x. How to edit registration page

    Adding registration form fields In order to add new fields to the registration form, database and fi ...

  3. 前端HTML与CSS编码规范

    HTML 语法 HTML5 doctype 语言属性(Language attribute) 字符编码 IE 兼容模式 引入 CSS 和 JavaScript 文件 实用为王 属性顺序 布尔(bool ...

  4. poj3667---Hotel 线段树区间合并,区间更新

    题意:有N个房间,M次操作.有两种操作(1)"1 a",表示找到连续的长度为a的空房间,如果有多解,优先左边的,即表示入住.(2)"2 b len",把起点为b ...

  5. linux文件系统学习

    linux系统支持很多种文件系统. 1. 如何确认当前系统挂载了哪些文件系统? 使用mount命令可以查看当前系统上已经挂载了哪些文件系统, sh-# mount rootfs on / type r ...

  6. phpcms:二、头部尾部包含

    1.index.html是默认的首页{template "content","header"}引入头部的模块{template "content&qu ...

  7. IOS UIlabel设置文本距离边框距离

    自定义UILabel 继承 UILabel 重写drawTextInRect 方法具体如下: CGRect rect = CGRectMake(rect.origin.x + 5, rect.orig ...

  8. Html5 Canvas 实现滚动的图片

    今天一直在找html5 canvas的使用实例.想画一张地图,再画个小车在上面跑.运气好找到了一个大神写的js代码.该代码实现了图片的左右来回滚动,现在粘贴在博客里记录一下: <html> ...

  9. web.xml中contextConfigLocation的作用(转)

    原文地址:http://blog.csdn.net/zhangliao613/article/details/6289114 原文格式较乱,此处略作整理.内容未变. 在web.xml中使用contex ...

  10. http接口测试浏览器插件

    http接口测试浏览器插件: Chrome: https://chrome.google.com/webstore/detail/chrome-poster/cdjfedloinmbppobahmon ...