首页 > 其他分享 >Notepad

Notepad

时间:2023-07-13 19:24:18浏览次数:38  
标签:operations le string ## Notepad ###

# Notepad#

## 题面翻译

### 题目描述

一开始打出的内容为空。现在你要打出一个长度为 $n$ 的字符串 $s$(全为英文小写字母组成),为此每次你可以进行如下操作中的一种:

- 在已打出内容的最后添加一个字符。
- 复制已打出内容的一个连续的子串并加到内容的末尾。

问你能不能在严格小于 $n$ 次操作下打出字符串 $s$?

### 输入格式

$t$ 组数据。第一行输入正整数 $t(1\le t\le10^4)$。

每组数据第一行输入正整数 $n$,第二行输入字符串 $s$。

单个测试点内所有 $n$ 之和不超过 $2\times10^5$。

### 输出格式

输出 $t$ 行,每行输出这组数据的答案。如果可以达到要求,输出 `YES`。否则输出 `NO`。

## 题目描述

You want to type the string $ s $ , consisting of $ n $ lowercase Latin letters, using your favorite text editor Notepad#.

Notepad# supports two kinds of operations:

- append any letter to the end of the string;
- copy a continuous substring of an already typed string and paste this substring to the end of the string.

Can you type string $ s $ in strictly less than $ n $ operations?

## 输入格式

The first line contains a single integer $ t $ ( $ 1 \le t \le 10^4 $ ) — the number of testcases.

The first line of each testcase contains a single integer $ n $ ( $ 1 \le n \le 2 \cdot 10^5 $ ) — the length of the string $ s $ .

The second line contains a string $ s $ , consisting of $ n $ lowercase Latin letters.

The sum of $ n $ doesn't exceed $ 2 \cdot 10^5 $ over all testcases.

## 输出格式

For each testcase, print "YES" if you can type string $ s $ in strictly less than $ n $ operations. Otherwise, print "NO".

## 样例 #1

### 样例输入 #1

```
6
10
codeforces
8
labacaba
5
uohhh
16
isthissuffixtree
1
x
4
momo
```

### 样例输出 #1

```
NO
YES
NO
YES
NO
YES
```

## 提示

In the first testcase, you can start with typing "codef" ( $ 5 $ operations), then copy "o" ( $ 1 $ operation) from an already typed part, then finish with typing "rces" ( $ 4 $ operations). That will be $ 10 $ operations, which is not strictly less than $ n $ . There exist other ways to type "codeforces". However, no matter what you do, you can't do less than $ n $ operations.

In the second testcase, you can type "labac" ( $ 5 $ operations), then copy "aba" ( $ 1 $ operation), finishing the string in $ 6 $ operations.

//Notepad#
//只需要寻找出字符串中是否存在不重叠的两个相同的子串就可以了,字串长度为2就可以了
//利用map存储
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+10,mod=1e9+7;
string s;
int n,t,a[N],f[N],res,num,ans,m;
bool vis[N];
signed main()
{
    std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>t;
    while(t--){
        cin>>n>>s;
            map<string,int>p;
            res=0;
            for(int i=0;i<s.size();i++){
                string tmp;
                tmp+=s[i];
                tmp+=s[i+1];
                if(p.count(tmp)==1&&p[tmp]!=i-1){
                    cout<<"YES"<<endl;
                    goto nexts;
                }
                if(!p.count(tmp)) p[tmp]=i;
            }
            cout<<"NO"<<endl;
            nexts:;
    }
    return 0;
}

 

标签:operations,le,string,##,Notepad,###
From: https://www.cnblogs.com/o-Sakurajimamai-o/p/17551861.html

相关文章

  • 使用Notepad++做下划线与驼峰的互换
    下划线转驼峰匹配规则:([a-z])_([a-z])替换规则:\1\U\2\E原:转换后:驼峰转下划线匹配规则:([a-z])([A-Z])替换规则:\1_\L\2\E原:转换后......
  • 批量添加字符串前后单引号(notepad)
    批量添加字符串前后的单引号和逗号准备数据:在此数据前后添加单引号和逗号,实现效果如下‘30’,A先加前面单引号首部添加了一个单引号:B再加后面的单引号和逗号最终把它放到表格、文本里面......
  • notepad++如何快速格式化代码
     2023-03-25 4505 广东举报简介: notepad++如何快速格式化代码Notepad++可以使用插件来快速格式化代码,以下是一种使用插件进行代码格式化的方法:打开Notepad++编辑器,并打开需要格式化的代码文件。在菜单栏中选择“插件”->“PluginManager”->“ShowPluginManag......
  • web | [Zer0pts2020]notepad
    web|[Zer0pts2020]notepad参考guoke师傅的文章:https://guokeya.github.io/post/3kK-0Vkzq/主要是ssti+pickle反序列化。首先通过ssti拿到flask的secret。之后通过伪造jwt的方式进行pickle反序列化的利用。生成pickle,这里我使用的是python3来反弹shell,flask肯定有这个环境,比......
  • notepad++删除包含指定字符串的行(正则)
    比如要去掉所有含有test的行的操作Ctrl+H打开替换窗口。(方式一)正则删除字符后,notepad++批量删除空行查找目标:^.test.$替换为:(空)查找模式,选择“正则表达式”删除空行,可通过notepad++的编辑->行操作->移除空行,来操作。(方式二)正则匹配,删除对应的行查找目标:^.test.\r?\n替......
  • notepad++ 怎么快速编辑多行行尾和行头
    1. ^符号代表行头  2. $代表行尾 ......
  • 关于NotePad++打开json文件并以树形方式展示
    NotePad++打开json文件并以树形方式展示为了更好查看和分析数据,需要将json数据展开去洞察数据规律,通常如果仅仅简单使用文本工具打开json文件,并不能很友好地观察出数据内容和规律,更不要说比较复杂的多层级的字典内容,因此需要以树形结构更好的观察json数据。为了更加清晰地说明问......
  • notepad++ c# ide 配置
    tag:notepad++c#IDE编译环境搭配 配置C#运行notpad++,点击“运行-》运行”菜单,出现一个弹出框,输入命令行,而后保存即可。1.编译cmd/kC:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe/out:"$(CURRENT_DIRECTORY)\$(NAME_PART).exe""$(FULL_CURRENT_PATH)"&......
  • 在notepad++软件上用正则表达式替换内容
    在notepad++软件上用正则表达式替换内容,查找:(\+\d+)|,在notepad++软件上用正则表达式替换内容示例要求:04,09,18,19,32,33+1403,04,13,18,25,32+0203,08,15,21,22,32+12把以上数据去掉+后面的数据,把分割逗号替换成空格的正则表达式,要在notepad++软件上可以使......
  • Notepad++之"常用技术"
    一、^前面数据准备  二、$后面准备结果 ......