题意翻译

有 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. 在html页面通过绝对地址显示图片

    1.编辑tomcat中conf目录下的server.xml文件,在<Host></Host>中添加如下代码段 <Context path="/D" d ...

  2. mobile app 与server通信的四种方式

    Have you ever wondered how the information gets into the application installed in your mobile device ...

  3. STL模板前言(1)

    STL提供以下数据结构方便使用: 顺序容器: vector(动态数组):从后面直接插入删除元素,直接访问任何元素. deque(双端队列):从前面和后面快速插入删除,直接访问任何元素. list(双链 ...

  4. how2heap学习(二)

    拖了好久,但是在期间做了几道pwn题目,发现堆原来也没有想象中的难. fastbin_dup_into_stack 这个说白了,就是利用double free可以进行任意地址的写,说是任意地址不准确, ...

  5. 数组基础(Excel函数集团)

    此处文章均为本妖原创,供下载.学习.探讨! 文章下载源是Office365国内版1Driver,如有链接问题请联系我. 请勿用于商业! 谢谢 下载地址:https://officecommunity- ...

  6. iNeuOS工业互联网操作系统,发布3.6.4版本:云端安全控制和实时日志功能,附Chrome、Firefox和Edge浏览器测试性能对比

    目       录 1.      概述... 2 2.      平台演示... 2 3.      云端控制和实时日志设计和技术... 2 4.      实时日志测试... 2 1.   概述 ...

  7. CF1130A Be Positive 题解

    Content 有一个长度为 \(n\) 的数组 \(a_1,a_2,a_3,...,a_n\),试找出一个数 \(d\),使得数组中的每个数除以 \(d\) 得到的 \(n\) 个结果中至少有 \( ...

  8. CF734B Anton and Digits 题解

    Content 有 \(k_2\) 个 \(2\).\(k_3\) 个 \(3\).\(k_5\) 个 \(5\) 和 \(k_6\) 个 \(6\),你可以用这里面的数字来组成 \(256,32\) ...

  9. 常用DBhelper封装方法

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...

  10. Java 中接口和抽象类的 7 大区别!

    本文已收录<Java常见面试题>:https://gitee.com/mydb/interview ​ Java 是一门面向对象的编程语言,面向对象的编程语言有四大特征:抽象.封装.继承和 ...