POJ 3096 Surprising Strings

SECS/GEM协议学习教程 摘要:SECS/GEM是半导体制造设备通信的国际标准,定义了主机系统与设备间的通信规范,包括设备控制、状态监控、数据采集等功能。协议采用分层架构(应用层、消息层、传输层、物理层),支持关键消息类型如S1F13(建立通信)、S2F13(数据采集)等。通信流程涵盖建立连接、数据交换和终止会话,并通过状态变量(SVID)、事件(CEID)等实现实时交互。典型应用包括设备初始化、报警处理及配方管理,需处理数据类型(如U2、A、L)和通信调试问题。 阅读详情


                                                         Surprising Strings
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 6884 Accepted: 4457

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


题意:给出一个一个字符串,找距离为D的两个字母组成一个字符串,看有没有重复的

比如 ZGBG

当 D=0 时,有ZG , GB , BG 都不相同

当 D=1 时,有ZB , GG  也不相同

当 D=2 时,有ZG 只有一个不想同

所以是 Surprising Strings


分析:暴力找,set


烂代码

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
#include <set>
#include <string>
#include <iostream>
using namespace std;
int main()
{
    char s[100];
    int n,m,i,j,l;
    while(~scanf("%s",s))
    {
        if(strcmp(s,"*")==0)
        {
            break;
        }
        l=strlen(s);
        if(l<=2)
        {
            printf("%s is surprising.\n",s);
            continue;
        }
        set<string>q;
        set<string>::iterator it;
        int flag=0;
        for(i=1;i<=l-1;i++)
        {
            q.clear();
            string x;
           // printf("%d\n",i);
            for(j=0;j<l;j++)
            {
                x.clear();
                if(j+i<l)
                {
                    x+=s[j];
                    x+=s[j+i];
                    x+='\0';
                }
                //cout<<x<<endl;
                if(x.size()!=0)
                {
                    if(q.find(x)==q.end())
                    {
                        q.insert(x);
                    }
                    else
                    {
                        flag=1;
                        break;
                    }
                }

//                for(it=q.begin();it!=q.end();it++)
//                {
//                    cout<<*it<<endl;
//                }
            }
            if(flag)
            {
                break;
            }
        }
        if(flag)
        {
            printf("%s is NOT surprising.\n",s);
        }
        else
        {
            printf("%s is surprising.\n",s);
        }

    }

    return 0;
}







扩展卡尔曼滤波 (EKF, Extended Kalman Filter) 算法详解及案例分析 扩展卡尔曼滤波是一种用于估计非线性动态系统状态的递归算法。其目标是通过结合非线性系统模型和观测数据,估计系统的最优状态。 阅读详情

相关推荐

【浙大翁恺】C语言习题

/* 02-0. 整数四则运算(10) 本题要求编写程序,计算2个正整数的和、差、积、商并输出。 题目保证输入和输出全部整型范围内。 输入格式: 输入在一行中给出2个正整数A和B。 输出格式: 在4行中按照格式“A 运算符 B = 结果”顺序输出和、差、积、商。 输入样例: 3 2 输出样例: 3 + 2 = 5 3 - 2 = 1 3 * 2 = 6 3 / 2 =.

qq_43600867的博客 5862

POJ-3096 Surprising Strings

POJ-3096 Surprising Strings 题目链接:POJ-3096 题目大意:这题题意我不会描述… 解题思路:利用map进行查找 利用goto跳出循环 代码块: #include<iostream> #include<map> #include<string> using namespace std; int main(){ string...

鱼头的水题之路 186

Caffeine:为每个元素动态设置过期时间

Caffeine利用expireAfter方法实现为每个元素动态设置过期时间

大数据开发、JAVA开发、人工智能AI 1万+

poj 3096 Surprising Strings

poj 3096 Surprising Strings 定义一种

youngkl博客 912

虚拟机ubuntu22.04.3中安装vitis2024.1注意事项

虚拟机ubuntu安装vitis2024.1

qq_52033578的博客 2496

DrissionPage实战:5分钟搞定京东滑块验证码自动登录(附完整轨迹生成代码)

本文详细介绍了如何使用DrissionPage工具实现京东滑块验证码的自动化登录,包括环境配置、滑块缺口识别、拟人化轨迹生成算法及完整登录流程。通过物理运动学模型和智能识别技术,有效提升验证码破解成功率,适用于电商自动化场景。

weixin_29229055的博客 244

POJ3096 Surprising Strings

POJ3096http://poj.org/problem?id=3096 题目大意:给定一串字符串,如果该字符串不论隔几个字符取两个字符都不会相等,则是“surprising" 否则就是"NOT surprising" 思路:错位比较,将原字符串每次向后移动一个字符位形成的新串与原字符串错位比较,如果有两个字符恰好相同则符合”NOT“的要求。 AC代码: #inc...

Sensente的博客 265

DolphinScheduler工作流中ChunJun任务保存失败的深度解析与实战修复

本文深度解析了在DolphinScheduler工作流中创建ChunJun任务时遭遇“parameter invalid”保存失败的普遍问题。其根源在于前端表单的`customConfig`参数默认值与后端校验逻辑不匹配。文章提供了两种实战修复方案:一是修改前端源码并重新编译,二是热更新已部署的JS文件,并对比了其适用场景与风险,帮助用户彻底解决此集成障碍。

weixin_29010003的博客 397

POJ 3096 Surprising Strings 可能会

woniupengpeng的专栏 185

二、ROS2完成Docker容器和宿主机通信,使用ros2 topic list看到,但是无法echo

如果容器和主机权限不一致,则会导致无法通信(我的代码中,docker容器是root,宿主机是普通用户),虽然可以查询到相关话题,但是订阅后没有消息输出。比如,docker容器创建了一个共享内存,其所有者为docker容器用户root,当宿主机去访问的时候,由于用户不同,没有权限访问,也就无法进行信息传递。该方法只是临时修改共享内存的权限,每次运行完,需要重新运行上述命令,才可以进行通信。在运行的过程中,ROS2使用了共享内存机制,会共享内存。运行之后,宿主机和容器可能用户名不同,这是因为。

qq_43280851的博客 1265

02 - GRACE数据处理步骤简叙

本篇对GRACE数据处理的过程进行了介绍,简单叙述了进行数据各种改正的原因,可以帮助理解GRACE数据处理理论,本文借鉴了多篇优秀博士论文。希望可以对👪有所帮助。

weixin_43339605的博客 3348

poj 3096——Surprising Strings

Surprising Strings Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7025   Accepted: 4550 Description The D-pairs of a string of letters are the ordered pairs

OPM的博客 381

修改yolov8使支持单通道图像输入

默认支持BGR三通道图像输入,但是在很多工业场景下,存在很多灰度图像的场景,因此对yolov8代码做一些修改以支持单通道图像输入,满足项目实际需求。训练时,只需要在 data 的 yaml 文件中,添加 ch=1 即可。

mingo_敏 5779

POJ 3096 -- Surprising Strings

POJ 3096 -- Surprising Strings 1 #include<iostream> 2 #include<map> 3 #include<cstring> 4 #include<string> 5 using namespace std; 6 char str[80]; 7 bool so...

weixin_30724853的博客 115

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

[POJ 3096]Surprising Strings[map]

题目链接:[POJ 3096]Surprising Strings[map] 题意分析: 相距0、1、2......s.length() - 1的两个字符所在的串集合中是否有重复的字符串,有则not,无则is。 解题思路: 枚举,map映射即可。 个人感受: 79长度,随意搞啊。 具体代码如下: #include #include #include #include #includ

闲停 484

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

POJ 3096 Surprising Strings 【STL】

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

u013180220的专栏 520

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

POJ3096—Surprising Strings

题目: 所述d-对字母的字符串的是有序对的是彼此的距离d字母。字符串是d-独特的,如果所有的d-对是不同的。的字符串是令人惊讶的,如果它是d-独特的每一个可能的距离D. 考虑串ZGBG。其0对是ZG,GB和BG。由于这三对都是不同的,ZGBG是0,唯一的。类似地,1-对ZGBG的是ZB和GG,并且由于这两个对是不同的,ZGBG是1-唯一的。最后,只有2对ZGBG的是ZG,所以ZGBG是2-唯一的。...

qq_44859533的博客 406

poj3096 Surprising Strings

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-uni

weixin_37483932的博客 237

POJ 3096.Surprising Strings

题目:http://poj.org/problem?id=3096 AC代码(C++): #include #include #include #include #include #define INF 0x3f3f3f3f using namespace std; int main() { char input[85]; while (cin >> input

njyexiong的博客 200

POJ3096-Surprising Strings

全解题报告索引目录 -> 【北大ACM – POJ试题分类】 转载请注明出处:http://exp-blog.com ------------------------------------------------------------------------- 大致题意: 定义D-pairs表示取字符串s中相距为D的两个字母所构成的字母对,该字母对中两个字母的位置顺序...

ζёСяêτ - 小優YoU 5240

POJ 3096 : Surprising Strings

CSU ACM

xibeiw的博客 274

POJ-3096-Surprising Strings

Surprising Strings Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7002   Accepted: 4532 Description The D-pairs of a string of letters are the ordered pairs

Ninaye的博客 278

POJ - 3096 Surprising Strings

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

起名好难呀! 208
上一篇: 2016 ccpc(长春站) 一个弱鸡的总结
下一篇: POJ Balanced Lineup 3264
K_y
K_y
博客等级 码龄10年 4粉丝 74原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值