题意翻译

有 n 个长度为 9 且只包含数字字符互不相同的串。

需要对于每个串找到一个长度最短的识别码,使得这个识别码当且仅当为这个串的子串。

题目分析

因为范围不是非常大,所以可以将子串筛出来

然后用STL统计即可

#include<bits/stdc++.h>
using namespace std;
int n;
string s[70005];
map<string,vector<int> >rec;
map<string,int >vis;
vector<string>cklfuck[70005];
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
cin>>s[i];
vis.clear();
for(int j=0;j<s[i].size();j++)
{
string ckl;
for(int k=j;k<s[i].size();k++)
{
ckl+=s[i][k];
if(!vis[ckl])
{
vis[ckl]=1;
rec[ckl].push_back(i);
} } }
}
for(map<string,vector<int> >::iterator it=rec.begin();it!=rec.end();it++)
{
pair<string,vector<int> >pi=(*it);
vector<int>saeds=pi.second;
if(saeds.size()==1)
{
string sf=(*it).first;
vector<int>::iterator id=saeds.begin();
int key=*id;
cklfuck[key].push_back(sf);
}
}
for(int i=1;i<=n;i++)
{
int mini=0x3f3f3f3f;
int keyi;
for(int j=0;j<cklfuck[i].size();j++)
{
string cjg=cklfuck[i][j];
if(mini>cjg.size())
{
mini=cjg.size();
keyi=j;
}
// cout<<cklfuck[i][j];
// printf("\n");
}
cout<<cklfuck[i][keyi];
printf("\n");
}
}

CF858D Polycarp's phone book的更多相关文章

  1. cf723c Polycarp at the Radio

    Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be re ...

  2. codeforces 723C : Polycarp at the Radio

    Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, th ...

  3. Codeforces 723C. Polycarp at the Radio 模拟

    C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...

  4. Codeforces Round #375 (Div. 2) C. Polycarp at the Radio 贪心

    C. Polycarp at the Radio time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  5. Codeforces Round #346 (Div. 2) F. Polycarp and Hay 并查集

    题目链接: 题目 F. Polycarp and Hay time limit per test: 4 seconds memory limit per test: 512 megabytes inp ...

  6. Polycarp's problems

    Polycarp's problems time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. Codeforce B. Polycarp and Letters

    B. Polycarp and Letters time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  8. [Codeforces 864B]Polycarp and Letters

    Description Polycarp loves lowercase letters and dislikes uppercase ones. Once he got a string s con ...

  9. 贪心 C - Polycarp's New Job

    Polycarp has recently got himself a new job. He now earns so much that his old wallet can't even sto ...

随机推荐

  1. SVN终端演练(个人开发\多人开发)

    SVN终端演练(个人开发) ### 1. 命令格式 命令行格式: svn <subcommand> [options] [args]       svn 子命令 [选项] [参数]     ...

  2. 【C#】【MySQL】C#连接MySQL数据库(一)代码

    C#连接MySQL数据库 准备工作 1.环境安装 安装MySQL For Visual Studio<<点击进入官网下载 第一个要下载安装,第二个下载后将MySQL.data添加到Visu ...

  3. win10更新后任务栏卡死 的原因和解决办法

    @ 目录 现象: 原因: 第一步:断网并关闭资讯和兴趣 第二步:卸载更新 第三步:关闭win10自动更新 第四步:永久关闭资讯和兴趣 现象: win10 更新后,开机任务栏卡死,点开始反应,设置页面无 ...

  4. Mysql脚本 优化检测

    下载地址: wget https://launchpad.net/mysql-tuning-primer/trunk/1.6-r1/+download/tuning-primer.sh 安装依赖: y ...

  5. shell脚本 mysqldump方式全备份mysql

    一.简介 源码地址 日期:2018/10/8 介绍:mysqldump方式全备份脚本,并保存固定天数的全备份 效果图: 二.使用 适用:centos6+ 语言:中文 注意:使用前先查看脚本,修改对应变 ...

  6. Windows通过计划任务定时执行bat文件

    第一步 第二步 第三步 第四步 第五步 第六步

  7. CF24B F1 Champions 题解

    Content 有 \(n\) 场已经进行完的赛车比赛,每场比赛给出前 \(m\) 名的名字.在每场比赛中,前 \(10\) 名的选手分别可以获得 \(25,18,15,12,10,8,6,4,2,1 ...

  8. java 多线程:线程通信-等待通知机制wait和notify方法;(同步代码块synchronized和while循环相互嵌套的差异);管道通信:PipedInputStream;PipedOutputStream;PipedWriter; PipedReader

    1.等待通知机制: 等待通知机制的原理和厨师与服务员的关系很相似: 1,厨师做完一道菜的时间不确定,所以厨师将菜品放到"菜品传递台"上的时间不确定 2,服务员什么时候可以取到菜,必 ...

  9. java 输入输出IO流 RandomAccessFile文件的任意文件指针位置地方来读写数据

    RandomAccessFile的介绍: RandomAccessFile是Java输入输出流体系中功能最丰富的文件内容访问类,它提供了众多的方法来访问文件内容,它既可以读取文件内容,也可以向文件输出 ...

  10. js Uncaught TypeError: undefined is not a function

    如下代码: var columns={}; var column={}: column.name='张三'; columns.push(column); 会出现Uncaught TypeError: ...