[水] POJ 3096
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 7659 | Accepted: 4878 |
Description
The D-pairs of a string of letters are the ordered pairs of letters that are distance D from each other. A string is D-unique if all of its D-pairs are different. A string is surprising if it is D-unique for every possible distance D.
Consider the string ZGBG. Its 0-pairs are ZG, GB, and BG. Since these three pairs are all different, ZGBG is 0-unique. Similarly, the 1-pairs of ZGBG are ZB and GG, and since these two pairs are different, ZGBG is 1-unique. Finally, the only 2-pair of ZGBG is ZG, so ZGBG is 2-unique. Thus ZGBG is surprising. (Note that the fact that ZG is both a 0-pair and a 2-pair of ZGBG is irrelevant, because 0 and 2 are different distances.)
Acknowledgement: This problem is inspired by the "Puzzling Adventures" column in the December 2003 issue of Scientific American.
Input
The input consists of one or more nonempty strings of at most 79 uppercase letters, each string on a line by itself, followed by a line containing only an asterisk that signals the end of the input.
Output
For each string of letters, output whether or not it is surprising using the exact output format shown below.
Sample Input
ZGBG
X
EE
AAB
AABA
AABB
BCBABCC
*
Sample Output
ZGBG is surprising.
X is surprising.
EE is surprising.
AAB is surprising.
AABA is surprising.
AABB is NOT surprising.
BCBABCC is NOT surprising.
Source
[Submit] [Go Back] [Status] [Discuss]
大暴力。。
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include<iostream>
#include <cmath>
#include<string>
#define ll long long
#define dscan(a) scanf("%d",&a)
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
#define MAXL 1105
#define maxn 1000005
int main()
{
string s;
string ss[];
while(cin>>s&&s!="*")
{
int l=s.length();
int flag;
if(l<=) {cout<<s<<" is surprising."<<endl;continue;}
for(int i=;i<l-;++i)
{
for(int j=;j<;++j) ss[i]="";
int cnt=;
flag=;
for(int j=;j<=l-i-;++j)
{
ss[cnt]=s[j]; ss[cnt++]+=s[j+i+];
for(int k=;k<cnt-;++k) {
if(ss[k]==ss[cnt-]) {
flag=;break;
}
}
if(!flag) break;
}
if(!flag) break;
}
if(flag) cout<<s<<" is surprising."<<endl;
else cout<<s<<" is NOT surprising."<<endl;
}
}
[水] POJ 3096的更多相关文章
- POJ 3096 Surprising Strings(STL map string set vector)
题目:http://poj.org/problem?id=3096 题意:给定一个字符串S,从中找出所有有两个字符组成的子串,每当组成子串的字符之间隔着n字符时,如果没有相同的子串出现,则输出 &qu ...
- POJ 3096 Surprising Strings
Surprising Strings Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5081 Accepted: 333 ...
- 【字符串题目】poj 3096 Surprising Strings
Surprising Strings Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6193 Accepted: 403 ...
- [ACM] POJ 3096 Surprising Strings (map使用)
Surprising Strings Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 5783 Accepted: 379 ...
- POJ 3096:Surprising Strings
Surprising Strings Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6258 Accepted: 407 ...
- poj很好很有层次感(转)
OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 30 ...
- POJ题目分类推荐 (很好很有层次感)
著名题单,最初来源不详.直接来源:http://blog.csdn.net/a1dark/article/details/11714009 OJ上的一些水题(可用来练手和增加自信) (POJ 3299 ...
- POJ 2502 - Subway Dijkstra堆优化试水
做这道题的动机就是想练习一下堆的应用,顺便补一下好久没看的图论算法. Dijkstra算法概述 //从0出发的单源最短路 dis[][] = {INF} ReadMap(dis); for i = 0 ...
- POJ 1488 Tex Quotes --- 水题
POJ 1488 题目大意:给定一篇文章,将它的左引号转成 ``(1的左边),右引号转成 ''(两个 ' ) 解题思路:水题,设置一个bool变量标记是左引号还是右引号即可 /* POJ 1488 T ...
随机推荐
- 3170: [Tjoi2013]松鼠聚会
Time Limit: 10 Sec Memory Limit: 128 MB Submit: 1804 Solved: 968[Submit][Status][Discuss] Descript ...
- (82)zabbix如何选择适合的监控类型
zabbix提供十几种监控类型,包括:Zabbix agent, Simple checks, SNMP, Zabbix internal, IPMI, JMX monitoring等等,那我们应该如 ...
- 小程序wafer2操作数据库
小程序操作数据库 //小程序控制台phpmyadmin里给数据库cAuth添加表 //controllers/hello.js const { mysql } = require('../qcloud ...
- SourceTree 跳过登录注册,直接使用
SourceTree下载安装后,运行程序会要求你登录或注册账号才能使用, 然而登录或注册基本都收不到服务器的响应 (在国外嘛,安全起见),于是卡在此处无法使用了. 下面就来介绍一下跳过这尴尬环节的方法 ...
- JAVA解析XML有哪几种方法?并简述各自的优缺点
DOM: 是用与平台和语言无关的方式表示XML文档的官方W3C标准,分析该结构通常需要加载整个文档和构造层次结构,然后才能做任何工作.是基于信息层次的 优点有:由于树在内存中是持久的,因此可以修改它以 ...
- 51nod 1202 不同子序列个数(计数DP)
1202 子序列个数 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 子序列的定义:对于一个序列a=a[1],a[2],......a[n].则非空序列a'=a[p1],a ...
- 笔记-python-变量作用域
笔记-python-变量作用域 1. python变量作用域和引用范围 1.1. 变量作用域 一般而言程序的变量并不是任何对象或在任何位置都可以访问的,访问权限决定于这个变量是在哪里赋 ...
- mysql-show processlist之writing to net
mysql提示Writing to net解决 最近发现某一个数据库cpu占用比较过.超过200%了. 首先查看数据库慢日志,设定慢日志5秒,基本上没有产生日,没有超过5秒的语句. show proc ...
- 12,scrapy框架之post请求
今日概要 递归爬取解析多页页面数据 scrapy的post请求发送 1.递归爬取解析多页页面数据 - 需求:将糗事百科所有页码的作者和段子内容数据进行爬取切持久化存储 - 需求分析:每一个页面对应一个 ...
- “帮你APP”团队冲刺5
1.整个项目预期的任务量 (任务量 = 所有工作的预期时间)和 目前已经花的时间 (所有记录的 ‘已经花费的时间’),还剩余的时间(所有工作的 ‘剩余时间’) : 所有工作的预期时间:88h 目前已经 ...