1410. Crack
http://acm.timus.ru/problem.aspx?space=1&num=1410
题目倒是不难,水题DP
就是题意理解起来有点困难,意思就是给你一段话,提取里面的单词
单词有小写字母和大写字母(某些单词的首部)组成 其他字符均为间隔,
而且不止一行,提取单词后,从里面选一定的单词,这些单词在原段中
不能相邻,然后让提取后所有单词总长最大
代码:
#include<iostream>
#include<stack>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<cmath> using namespace std; typedef long long ll;
typedef pair<int,int> pp;
const int INF=0x3f3f3f3f;
const int N=10003;
int d1[N],d2[N];
int a[N];
char s[N*100];
int main()
{
//freopen("data.in","r",stdin); int ln=0;
char c;
while(scanf("%c",&c)!=EOF)
s[ln++]=c; int l=0;
while(s[l]==' '&&l<ln)++l; int n=0;
int k=0;
for(int i=l;i<=ln;++i)
{
if((s[i]<='z'&&s[i]>='a')||(s[i]<='Z'&&s[i]>='A'))
++k;
else
{
if(k>0)
a[n++]=k;
k=0;
}
if(i==ln) break;
}
memset(d1,0,sizeof(d1));
memset(d2,0,sizeof(d2));
d1[0]=a[0];d2[0]=0;
for(int i=1;i<=n-1;++i)
{
d1[i]=a[i]+d2[i-1];
d2[i]=max(d1[i-1],d2[i-1]);
} cout<<max(d1[n-1],d2[n-1]);
return 0;
}
1410. Crack的更多相关文章
- id0-rsa WP合集
忙里偷闲做做题wwwwwwwwwwwww Intro to Hashing Intro to PGP Hello PGP Hello OpenSSL Intro to RSA Caesar Hello ...
- reversing-Easy Crack
Easy Crack 程序启动后输入任意字符会显示一个MessageBox的Incorrect Password. 打开OllyDbg,载入程序后查找到目标字符串Incorrect Password, ...
- crack.vbs病毒,优盘里所有文件全变成快捷方式
去了一趟学校打印店,用优盘copy打印了点东西,当时在打印店电脑里打开优盘的时候里面就变成了快捷方式,但没怎么在意.回来之后在自己电脑上居然也这样了.网上一搜是中了crack.vbs病毒了.格式化优盘 ...
- MATLAB的crack安装小曲
MATLAB的crack安装小曲 本学期要学数学模型和数值分析,需要用MATLAB,便琢磨着装MATLAB.我同专业的同学会装MATLAB的crack,他是数学协会的理事长,平时爱吹牛,问他一个简单的 ...
- sdut 2165:Crack Mathmen(第二届山东省省赛原题,数论)
Crack Mathmen Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 Since mathmen take securit ...
- poj 1410 线段相交判断
http://poj.org/problem?id=1410 Intersection Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- MITM to crack Https connections
Everybody knows that https is http over SSL, and https is a secure way for protecting confidential d ...
- URAL1410. Crack
1410 dp水题 题意读了好一会 是不能连续读两个及以上单词 #include <iostream> #include<cstdio> #include<cstring ...
- 线段和矩形相交 POJ 1410
// 线段和矩形相交 POJ 1410 // #include <bits/stdc++.h> #include <iostream> #include <cstdio& ...
随机推荐
- TCP、UDP、IP协议分析
此篇文章的原创作者是:草根老师博客(程姚根) chengyaogen.blog.chinaunix.net 感谢原作者! 互连网早期的时候,主机间的互连使用的是NCP协议.这种协议本身有很多缺陷,如: ...
- Bug测试报告--连连看——天天向上
测试时间:2016-11-23 20:10 测试者:刘芳芳(nice!团队) 代码地址:HTTPS:https://git.coding.net/jx8zjs/llk.git SSH:git@git. ...
- 15. 星际争霸之php设计模式--策略模式
题记==============================================================================本php设计模式专辑来源于博客(jymo ...
- ruby基础语法
首发:个人博客,更新&纠错&回复 学不同语言,常将它们的基础语法搞混,例如if后面有没有(),后面是then还是:还是{,结尾是end还是}. 这种事情毫无技术含量又毫无乐趣可言,但极 ...
- [转]http://m635674608.iteye.com/blog/1750833
转载地址:http://m635674608.iteye.com/blog/1750833 在第一次使用TortoiseSVN从服务器CheckOut的时候,会要求输入用户名和密码,这时输入框下面有个 ...
- extjs 一些杂碎的技术问题
1怎样将grid 的checkedbox 勾选状态都清除 inv.getSelectionModel().clearSelections(); inv.getView().refresh(); 2怎样 ...
- 2015弱校联盟(2) - J. Usoperanto
J. Usoperanto Time Limit: 8000ms Memory Limit: 256000KB Usoperanto is an artificial spoken language ...
- VS2012下基本类型大小
- 【leetcode❤python】 203. Remove Linked List Elements
#-*- coding: UTF-8 -*- # Definition for singly-linked list.# class ListNode(object):# def __init ...
- Java中的static关键字解析 转载
原文链接:http://www.cnblogs.com/dolphin0520/p/3799052.html Java中的static关键字解析 static关键字是很多朋友在编写代码和阅读代码时碰到 ...