A - Surprising Strings

题意就是给你一个字符串,例如ZGBG,有一种称谓叫D-unique

这个字符串 在D=0时, 有三个子串 ZG GB BG,因为这三个都不同,也就是unique,所以ZGGB是 0-unique;

同理               D=1时,有两个子串ZB GG也是不同,所以ZGGB是 1-unique;

D=2时,只有一个子串ZG,独一无二,所以ZGGB是 2-unique;

ince these three pairs are all different,Thus ZGBG is surprising.因为这三个都是独一无二的,所以满足题目要求;

用map建立每个子串与数字的联系来统计,很方便。

#include<iostream>//暴力
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
const int mod=100007;
using namespace std;
char s[100];
int ans(){
int l,d,i,j;
l=strlen(s);
if(l<3)
return 1;
d=1;
while(d<l){
for(i=0;i<l-d;i++){
for(j=i+1;j<l-d;j++){
if(s[i]==s[j]&&s[i+d]==s[j+d])
return 0;
}
}
d++;
}
return 1;
}
int main(){
while(scanf("%s",s)){
if(s[0]=='*')
return 0;
if(ans())
printf("%s is surprising.\n");
else
printf("%s is NOT surprising.\n");
}
return 0;
}

  

#include<iostream>
#include<string>
#include<map>
#include<cstdio>
#include<stdio.h>
#include<string.h>
using namespace std;
const int kMaxn(2007); int main()
{ char str[10005],pair[3];
map<string,int> r;
while(scanf("%s",str) != EOF)
{
if(str[0] == '*')
break;
int leap,i,len,j;
len = strlen(str);
for(i = 0;i < len;i++)
{
leap = 1;
r.clear();
for(j = 0;j < len-i-1;j++)
{
pair[0] = str[j];
pair[1] = str[j+i+1];
pair[2] = '\0';
r[pair]++;
if(r[pair] > 1)
leap = 0;
}
if(leap == 0)
break;
}
if(leap)
printf("%s is surprising.\n",str);
else
printf("%s is NOT surprising.\n",str);
} return 0;
}

  

2017中南大学暑期集训day1 : debug&STL-A的更多相关文章

  1. HZNU-ACM寒假集训Day1小结 STL 并查集

    常用STL 1.优先队列 priority_queue 内部是用堆(heap)实现的 priority_queue<int> pq; 默认为一个“越小的整数优先级越低的优先队列” 对于一些 ...

  2. 「2017 山东三轮集训 Day1」Flair

    模拟赛的题 好神仙啊 题面在这里 之前的Solution很蠢 现在已经update.... 题意 有$ n$个商品价格均为$ 1$,您有$ m$种面值的货币,面值为$ C_1..C_m$ 每种物品你有 ...

  3. 8.4 正睿暑期集训营 Day1

    目录 2018.8.4 正睿暑期集训营 Day1 A 数对子 B 逆序对 C 盖房子 考试代码 A B C 2018.8.4 正睿暑期集训营 Day1 时间:4.5h(实际) 期望得分:30+50+3 ...

  4. LOJ 6060「2017 山东一轮集训 Day1 / SDWC2018 Day1」Set(线性基,贪心)

    LOJ 6060「2017 山东一轮集训 Day1 / SDWC2018 Day1」Set $ solution: $ 这一题的重点在于优先级问题,我们应该先保证总和最大,然后再保证某一个最小.于是我 ...

  5. 2019暑期金华集训 Day1 组合计数

    自闭集训 Day1 组合计数 T1 \(n\le 10\):直接暴力枚举. \(n\le 32\):meet in the middle,如果左边选了\(x\),右边选了\(y\)(且\(x+y\le ...

  6. 2019暑期金华集训 Day1 数据结构

    自闭集训 Day1 数据结构 CF643G 用类似于下面的方法,搬到线段树上. 如何合并两个集合?先全部放在一起,每次删掉最小的\(cnt_i\),然后把其他所有的\(cnt\)都减去\(cnt_i\ ...

  7. 8.9 正睿暑期集训营 Day6

    目录 2018.8.9 正睿暑期集训营 Day6 A 萌新拆塔(状压DP) B 奇迹暖暖 C 风花雪月(DP) 考试代码 A B C 2018.8.9 正睿暑期集训营 Day6 时间:2.5h(实际) ...

  8. 2014年CCNU-ACM暑期集训总结

    2014年CCNU-ACM暑期集训总结 那个本期待已久的暑期集训居然就这种.溜走了.让自己有点措手不及.很多其它的是对自己的疑问.自己是否能在ACM这个领域有所成就.带着这个疑问,先对这个暑假做个总结 ...

  9. 【欧拉回路+最小生成树】SD开车@山东2018省队一轮集训day1

    目录 [欧拉回路+最小生成树]SD开车@山东2018省队一轮集训day1 PROBLEM 题目描述 输入 输出 样例输入 样例输出 提示 SOLUTION CODE [欧拉回路+最小生成树]SD开车@ ...

随机推荐

  1. [BZOJ4920][Lydsy六月月赛]薄饼切割

    [BZOJ4920][Lydsy六月月赛]薄饼切割 试题描述 有一天,tangjz 送给了 quailty 一张薄饼,tangjz 将它放在了水平桌面上,从上面看下去,薄饼形成了一个 \(H \tim ...

  2. CentOS系统缺少库文件解决办法

    By francis_hao    May 31,2017   程序在编译时出现缺少库文件的提示,如下: as: error while loading shared libraries: libz. ...

  3. innodb_stats_on_metadata and slow queries on INFORMATION_SCHEMA

    INFORMATION_SCHEMA is usually the place to go when you want to get facts about a system (how many ta ...

  4. Codeforces Round #520 (Div. 2) B. Math

    B. Math time limit per test:1 second memory limit per test:256 megabytes Description: JATC's math te ...

  5. selenium 获取某个元素的html

    <table> <tbody id="tb-37327761306"> <tr class="sep-row"><td ...

  6. 获取oracle当前系统设置了哪些事件

    ALTER SESSION SET EVENTS '10046 trace name context forever,level 12' 会话已更改. DECLARE EVENT_LEVEL NUMB ...

  7. C/C++常考面试题(二)

    网上看到的面经,说是dynamic_cast的实现,和RTTI的相关,这才发现原来对这个概念这么模糊,所以作了这个总结. C/C++常考面试题(二) RTTI(Runtime Type Informa ...

  8. vivo面试学习3(git和svn的区别)

    git和svn有什么区别? svn: 系统特点: 1).集中式版本控制系统(存在一个中央版本库,所有开发人员所使用的代码都是来源于版本库,提交代码也是这个中央版本库) 2).企业内部并行集中开发 3) ...

  9. 【Foreign】猜测 [费用流]

    猜测 Time Limit: 10 Sec  Memory Limit: 256 MB Description Input Output Sample Input 3 1 1 1 2 2 1 Samp ...

  10. Bzoj3441 乌鸦喝水

    Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 258  Solved: 97 Description [题目背景]     一只乌鸦在自娱自乐,它在面 ...