题意翻译

有 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. javascript将平行的拥有上下级关系的数据转换成树形结构

    转换函数 var Littlehow = {}; /** * littlehow 2019-05-15 * 平行数据树形转换器 * @type {{format: tree.format, sort: ...

  2. C++易错小结

    C++ 11 vector 遍历方法小结 方法零,对C念念不舍的童鞋们习惯的写法: void ShowVec(const vector<int>& valList) { int c ...

  3. ssm+mysql+jsp打造在线考试系统WeKnow-学生端

    一.登陆模块 前台提交账号和密码传到后台处理控制层 1.1 首先是控制器 @RequestMapping(value="/studentLogin", method=Request ...

  4. 用法总结:NSArray,NSSet,NSDictionary

    用法总结:NSArray,NSSet,NSDictionary Foundation framework中用于收集cocoa对象(NSObject对象)的三种集合分别是: NSArray 用于对象有序 ...

  5. 12.16 Java继承

    首先 :继承,指一个对象直接使用另一对象的属性和方法. 继承的格式: public class 子类名 entends 父类名{}   /* 表示前面的子类继承父类 */ 例:public class ...

  6. UNCTF2020 pwn题目

    YLBNB 用pwntools直接连接,然后接受就行. 1 from pwn import * 2 3 p = remote('45.158.33.12',8000) 4 context.log_le ...

  7. CSS选择器类型总结

    CSS选择器类型总结 1.通用选择器 一般用于给所有元素做一些通用性的样式设置,比如清除内边距.外边距等.但是效率比较低,尽量不要使用. * { margin: 0; padding: 0; } 2. ...

  8. CF1428A Box is Pull 题解

    Content 有一个兔子拖着一个盒子在走,每秒钟可以带着盒子走一个单位,也可以不带着盒子走一个单位.当且仅当兔子和盒子的距离不超过 \(1\) 时可以带着盒子走一个单位.现给出 \(t\) 次询问, ...

  9. nim_duilib(11)之menu(1)

    introduction 更多控件用法,请参考 here 和 源码. 本文的代码基于这里 本文将介绍menu控件 xml文件添加代码 基于上一篇, 继续向basic.xml中添加下面的代码. xml完 ...

  10. c++之升序和降序排序

    1.头文件 #include <functional> 2. 降序 // 期末成绩 int score[] = {99, 77, 30, 80}; // 1. 降序排列 std::sort ...