hdu 5688 2016"百度之星"
来源:互联网 发布:特战旅php 编辑:程序博客网 时间:2024/06/03 13:47
点这里
。。不知道map的用法就一直TLE
map:可以用来遍历数据
声明
map<string, int> cc;代码:
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <algorithm>#include <map>using namespace std;char x[41];//char cc[100000][41];int ans[100000];map<string, int> cc;int main(){ int t; while(~scanf("%d",&t)) { getchar(); int k=0; memset(ans,0,sizeof(ans)); for(int i=0; i<t; i++) { memset(x,0,sizeof(x)); gets(x); sort(x,x+strlen(x)); printf("%d\n",cc[x]++); } } return 0;}
= =这个是一直TLE的代码
暴力害人
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <algorithm>using namespace std;char x[41];char cc[100000][41];int ans[100000];int main(){ int t; while(~scanf("%d",&t)) { getchar(); int k=0; memset(ans,0,sizeof(ans)); for(int i=0; i<t; i++) { memset(x,0,sizeof(x)); gets(x); int j; sort(x,x+strlen(X)); if(i==0) { ans[0]=0; strcpy(cc[k++],x); printf("%d\n",ans[0]); } else { for(j=0; j<k; j++) { if(strcmp(cc[j],x)==0) { ans[j]++; break; } } if(j==k) { strcpy(cc[k++],x); } printf("%d\n",ans[j]); } } } return 0;}
阅读全文
0 0
- hdu 5688 2016"百度之星"
- HDU 5688:2016"百度之星" - 资格赛 Problem D
- hdu 5687 百度之星2016 C
- 2016百度之星 hdu 5701 模拟
- 2014~2016百度之星hdu题目
- hdu 5685 2016"百度之星"
- HDU 5688 16百度之星预选赛D
- HDU 5685:2016"百度之星" - 资格赛 Problem A
- HDU 5686:2016"百度之星" - 资格赛 Problem B
- HDU 5690:2016"百度之星" - 初赛 All X
- 2016百度之星 hdu 5690 矩阵快速幂
- 2016百度之星 hdu 5695 拓扑序+优先队列
- 2016百度之星 hdu 5696 RMQ+单调栈
- 2016百度之星 hdu 5698 递推+费马小
- 2016百度之星 hdu 5700 分析+优先队列
- HDU 5698 瞬间移动(百度之星2016)
- HDU-5687 Problem C(2016"百度之星"-资格赛)
- 2016 百度之星资格赛题解(hdu 5685,5686,5687,5688,5689)
- 浏览器内核
- Django模型
- RoboWare的相关记录
- c++学习-智能指针学习
- UVA116UnidirectionalTSP
- hdu 5688 2016"百度之星"
- c# 三目运算&foreach语句
- R语言-RC系统
- CacheUtil(loadingCache)
- MyEclipse快捷键大全
- 【ARM】Exynos 4412 中断控制器相关计算
- 51nod 1284 2 3 5 7的倍数
- Maven资源仓库配置
- 【转】【NGN学习笔记】6 代理(Proxy)和背靠背用户代理(B2BUA)