https://vjudge.net/problem/CodeForces-633C

http://codeforces.com/problemset/problem/633/C

点击这里看巨佬题解

#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int M=;
int n,m,dp[M],l[M],tot=,now,ll,pos[M];
char s[M],t[M];
vector<int>v;
struct node{
int ed,son[];
node(){
ed=;
memset(son,,sizeof(son));
}
}tree[];
void insert(int k){
now=;
int q;
for(int i=ll+;i<=l[k]+ll;i++){
if(t[i]<'a')q='a'-'A';else q=;
if(tree[now].son[t[i]-'a'+q]==){
tot++;
tree[now].son[t[i]-'a'+q]=tot;
}
now=tree[now].son[t[i]-'a'+q];
}
tree[now].ed=k;
return;
}
int main(){
cin>>n;
cin>>s+;
cin>>m;
for(int i=;i<=m;i++){
cin>>t+ll+;
pos[i]=ll+;
l[i]=strlen(t+ll+);
insert(i);
ll+=l[i];
}
dp[]=;
for(int i=;i<=n;i++){
now=;
for(int j=;j<=i&&now;j++){
now=tree[now].son[s[i-j+]-'a'];
if(tree[now].ed&&dp[i-j]){
dp[i]=tree[now].ed;
break;
}
}
}
for(int i=n;i>=;i-=l[dp[i]]){
v.push_back(dp[i]);
}
int ss=v.size();
for(int i=ss-;i>=;i--){
for(int j=;j<=l[v[i]];j++){
putchar(t[pos[v[i]]+j-]);
}
putchar(' ');
}
return ;
}

CF633C:Spy Syndrome 2——题解的更多相关文章

  1. CF633C Spy Syndrome 2

    嘟嘟嘟 题面:把一句话加密:1.所有字母变成小写.2.翻转所有单词.3.去掉空格.然后给你一句加密后的字符串以及一些出现在原句和没有出现在原句的单词,让你还原原句.注意,每一个单词可以使用多次,如果有 ...

  2. CF633C Spy Syndrome 2 trie树

    这个模型以前绝对见过,模拟赛的时候开始敲了一个AC自动机,纯属脑抽~ code: #include <bits/stdc++.h> #define N 5000006 #define NN ...

  3. Manthan, Codefest 16 C. Spy Syndrome 2 字典树 + dp

    C. Spy Syndrome 2 题目连接: http://www.codeforces.com/contest/633/problem/C Description After observing ...

  4. Manthan, Codefest 16 -C. Spy Syndrome 2

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  5. codeforces 633C. Spy Syndrome 2 hash

    题目链接 C. Spy Syndrome 2 time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  6. Codeforces 633C Spy Syndrome 2 | Trie树裸题

    Codeforces 633C Spy Syndrome 2 | Trie树裸题 一个由许多空格隔开的单词组成的字符串,进行了以下操作:把所有字符变成小写,把每个单词颠倒过来,然后去掉单词间的空格.已 ...

  7. Codeforce 633.C Spy Syndrome 2

    C. Spy Syndrome 2 time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  8. CF#633C Spy Syndrome 2 DP+二分+hash

    Spy Syndrome 2 题意 现在对某个英文句子,进行加密: 把所有的字母变成小写字母 把所有的单词反过来 去掉单词之间的空格 比如:Kira is childish and he hates ...

  9. Codeforce 633C. Spy Syndrome 2

    C. Spy Syndrome 2 time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

随机推荐

  1. nested class 例子

    #include<iostream> using namespace std; /* start of Enclosing class declaration */ class Enclo ...

  2. 如何搭建本地svn服务器和搭建本地Git服务器

    搭建git本地服务器使用的软件有很多,例如:gitlab,gitblit,gitbucket,gogs,gitolite,具体比较:http://softlab.sdut.edu.cn/blog/su ...

  3. 获取ip地址以及获取城市等信息

    class Program { static void Main(string[] args) { string ip = GetIP(); if (ip != null) { string city ...

  4. JAVA基础学习之路(八)[1]String类的基本特点

    String类的两种定义方式: 直接赋值 通过构造方法赋值 //直接赋值 public class test2 { public static void main(String args[]) { S ...

  5. 孤荷凌寒自学python第七十七天开始写Python的第一个爬虫7

    孤荷凌寒自学python第七十七天开始写Python的第一个爬虫7 (完整学习过程屏幕记录视频地址在文末) 今天在上一天的基础上继续完成对我的第一个代码程序的书写. 今天的学习仍然是在纯粹对docx模 ...

  6. Ubuntu—终端命令调整窗口的大小

    1,查看窗口大小 current 1280x768 是我当前电脑的窗口大小,下面提供的是可以修改的窗口大小. $ xrandr 2.修改窗口大小 示例: $ xrandr -s 1024x768

  7. python常用命令—终端安装win32的两种方法

    1, pip install pywin32 2, pip install pypiwin32

  8. UVa 455 - Periodic Strings - ( C++ ) - 解题报告

    1.题目大意 求一个长度不超过80的字符串的最小周期. 2.思路 非常简单,基本就是根据周期的定义做出来的,几乎不需要过脑. 3.应该注意的地方 (1) 最后输出的方式要注意,不然很容易就PE了.不过 ...

  9. 【SSH进阶之路】Struts + Spring + Hibernate 进阶开端(一)

    [SSH进阶之路]Struts + Spring + Hibernate 进阶开端(一) 标签: hibernatespringstrutsssh开源框架 2014-08-29 07:56 9229人 ...

  10. appcan打包后产生的问题总结

    以appcan为基础的项目,最终需要打包后进行调试.在调试过程中,主要的样式问题在苹果手机上,下面将这些问题总结起来,以防下次再犯. 1:ios 7 以上的手机中,状态栏与内容重叠: 问题描述:在io ...