【CodeForce】 4C Registration system(map乱搞)
来源:互联网 发布:g92调多头螺纹怎么编程 编辑:程序博客网 时间:2024/06/18 12:51
思路:用map存一下出现的字符串,以及衍生出来的字符串个数就可以了。
之前只是单纯记录是否出现,结果超时。
只要记录衍生出来的字符串,下一次直接跳到最后那一个,判断,即可。
#define _CRT_SECURE_NO_WARNINGS#include<iostream>#include<map>#include<cstdio>#include<cstring>#include<string>using namespace std;char str[110];char str1[110];void tostr(int temp){int cur = 0;while (temp){str1[cur++] = temp % 10+48;temp /= 10;str1[cur] = 0;}reverse(str1, str1 + cur);}int main(){int n;while (~scanf("%d", &n)){map<string, int>s;while (n--){scanf("%s", str);int len = strlen(str);if (s.find(str)==s.end()){puts("OK");s[str] = 1;}else{int temp = 0;while (s[str]){temp += s[str];tostr(temp);str[len] = 0;strcat(str, str1);}s[str] = 1;puts(str);str[len] = 0;s[str]++;}}}}
0 0
- 【CodeForce】 4C Registration system(map乱搞)
- 4C - Registration System【map】
- 【CODEFORCE 4C】map容器的妙用——Registration system
- CodeForces 4C Registration system(字符串处理 | map)
- cf 4c Registration system (map学习)
- Codeforces 4C-Registration system(map)
- Codeforces 4C Registration system (map)
- Codeforces 4C Registration System map的应用
- code forces 4C Registration system (map 的简单用法)
- codeforces 4c Registration system 字符串 map应用
- CF 4C Registration system
- codeforces 4C Registration system
- codeforces 4C Registration system
- codeforces 4c Registration system
- Codeforces 4C. Registration system
- CodeForces 4C. Registration system
- CodeForces 4C-Registration system
- codeforces-4C-Registration system
- Python字符串格式化
- sdut 2609 A-Number and B-Number (数位dp,二分答案)
- 100句充满智慧的人生格言
- IplImage, CvMat, Mat 的关系和相互转换(转)
- Android 4.4从图库选择图片,获取图片路径并裁剪
- 【CodeForce】 4C Registration system(map乱搞)
- iPhone之UISplitViewController
- 指引人生方向的金玉良言
- 安装 Kali Linux 后需要做的 20 件事
- 黑马程序员—面向对象封装继承多态
- GDB 和strace 使用和移植
- js 不能直接将 console.log 作为参数使用
- Maps--HashMap, LinkedHashMap, TreeMap
- 保持积极向上的人生格言