北大ACM(POJ1002-487-3279)
Question:http://poj.org/problem?id=1002
问题点:字符映射、选重复项及排序。
Memory: 1136K Time: 813MS
Language: C++ Result: Accepted
4 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream> using namespace std;
const char mp[]={'','','','','','','','','','','','','','','','','','','','','','','','',''};
int mycmp(const void *a,const void *b)
{
return strcmp((char*)a,(char*)b);
}
int main()
{
bool duplicate=false;
int len;
char c[];//TIPS:该数组需要足够大的空间
char phone[][];//由于字符数组需要'\0'作为结束符,所以增加一位
memset(phone,,sizeof(phone));
cin>>len;
getwchar();
for(int i=;i<len;i++)
{
cin>>c;
int clen=strlen(c);
for(int ch=,j=;ch<clen;ch++)
{
if(c[ch]=='-') continue;
if(j==) phone[i][j++]='-';
if(c[ch]>='A'&&c[ch]<'Z') c[ch]=mp[c[ch]-'A'];
phone[i][j++]=c[ch];
}
}
qsort(phone,len,sizeof(phone[]),mycmp);
for(int m=,cnt=;m<len-;m++)
{
if(strcmp(phone[m],phone[m+])==)
{
cnt++;
duplicate=true;
if(m==len-) cout<<phone[m]<<" "<<cnt<<endl;
}
else
{
if(cnt>) cout<<phone[m]<<" "<<cnt<<endl;
cnt=;
}
}
if(!duplicate)
{
cout<<"No duplicates."<<endl;
}
return ;
}
北大ACM(POJ1002-487-3279)的更多相关文章
- 北大ACM - POJ试题分类(转自EXP)
北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...
- 北大 ACM 分类 汇总
1.搜索 //回溯 2.DP(动态规划) 3.贪心 北大ACM题分类2009-01-27 1 4.图论 //Dijkstra.最小生成树.网络流 5.数论 //解模线性方程 6.计算几何 //凸壳.同 ...
- 北大ACM题库习题分类与简介(转载)
在百度文库上找到的,不知是哪位大牛整理的,真的很不错! zz题 目分类 Posted by fishhead at 2007-01-13 12:44:58.0 -------------------- ...
- 北大ACM试题分类+部分解题报告链接
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...
- 北大ACM - POJ试题分类
1.入门水题 可用于练手与增强自信 POJ-1003POJ-1004 POJ-1005 POJ-1207 POJ-3299 POJ-2159 POJ-1083POJ-3094 2.初级 2.1. 基本 ...
- 北大ACM(POJ1014-Dividing)
Question:http://poj.org/problem?id=1014 问题点:抽屉原理.dfs.多重背包. Memory: 248K Time: 16MS Language: C++ Res ...
- 北大ACM(POJ1013-Counterfeit Dollar)
Question:http://poj.org/problem?id=1013 问题点:排除+验证. Memory: 244K Time: 16MS Language: C++ Result: Acc ...
- 北大ACM(POJ1012-Joseph)
Question:http://poj.org/problem?id=1012 问题点:约瑟夫环. Memory: 220K Time: 329MS Language: C++ Result: Acc ...
- 北大ACM(POJ1010-STAMPS)
Question:http://poj.org/problem?id=1010问题点:DFS.剪枝. Memory: 220K Time: 32MS Language: C++ Result: Acc ...
- 北大ACM(POJ1009-Edge Detection)
Question:http://poj.org/problem?id=1009问题点:RLE编码. Memory: 648K Time: 547MS Language: C++ Result: Acc ...
随机推荐
- 红帽 Enterprise Linux OpenStack Platform 4.0全面上市
十一月,红帽公司推出Red Hat Enterprise Linux OpenStack Platform 4.0测试版,这款企业级解决方案集Red Hat Enterprise Linux的稳定性与 ...
- Debug with jdb
原文地址: http://www.javaworld.com/article/2077445/testing-debugging/debug-with-jdb.html Q: How do you u ...
- Hadoop on Mac with IntelliJ IDEA - 3 解决MRUnit - No applicable class implementing Serialization问题
本文讲述在IntelliJ IDEA中使用MRUnit 1.0.0测试Mapper派生类时因MapDriver.withInput(final K1 key, final V1 val)的key参数被 ...
- BZOJ 2152: 聪聪可可 点分治
2152: 聪聪可可 Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php ...
- delphi 如何知道 Treeview,Listview 当前最上面显示的节点
如何知道 Treeview,的节点是根节点 procedure TForm1.TreeView1ContextPopup(Sender: TObject; MousePos: TPoint ...
- Binder机制1---Binder原理介绍
1.Binder通信机制介绍 这篇文章会先对照Binder机制与Linux的通信机制的区别,了解为什么Android会另起炉灶,採用Binder.接着,会依据Binder的机制,去理解什么是Servi ...
- 免费的天气预报API--谷歌,雅虎,中央气象台
Google Weather API 仅仅支持美国地区使用邮政编码进行查询,比如: http://www.google.com/ig/api?hl=zh-cn&weather=94043 ...
- php的引用&(就是在变量或者函数、对象等前面加上&符号)
官方文档: 1.引用是什么:http://www.php.net/manual/zh/language.references.whatare.php 2.引用做什么:http://www.php.ne ...
- 自动监控主从MySQL同步的SHELL脚本
代码如下: #!/bin/bash #check MySQL_Slave Status #crontab time 00:10 MYSQLPORT=`netstat -na|grep "LI ...
- Pass value from child popup window to parent page window using JavaScript--reference
Here Mudassar Ahmed Khan has explained how to pass value from child popup window to parent page wind ...