北大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 ...
随机推荐
- 简谈 JavaScript、Java 中链式方法调用大致实现原理
相信,在 JavaScript .C# 中都见过不少链式方法调用,那么,其中实现该类链式调用原理,大家有没有仔细思考过?其中 JavaScript 类库:jQuery 中就存在大量例子,而在 C# 中 ...
- 参数对象Struts2中Action的属性接收参数
题记:写这篇博客要主是加深自己对参数对象的认识和总结实现算法时的一些验经和训教,如果有错误请指出,万分感谢. Action中三种传递并接受参数: 1. 在Action添加成员属性接受参数 例如请求的 ...
- 【M8】了解各种不同意义的new和delete
1.首先考虑new operator,new operator 可以认为做了三件事情:a.调用operator new分配一块内存:b.在这块内存上调用构造方法构造对象:返回指针. 2.operato ...
- AlertView with password
1. setAlertViewStyle:UIAlertViewStyleSecureTextInput UIAlertView *alertView = [[UIAlertView alloc] i ...
- Codeforces Round #313 (Div. 2) A. Currency System in Geraldion 水题
A. Currency System in Geraldion Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/c ...
- Android版本号的识别——$(PLATFORM_VERSION)
#/******************************************************************************#*@file Android.mk#* ...
- 【ZZ】常用推荐算法
http://liyonghui160com.iteye.com/blog/2082450 在推荐系统简介中,我们给出了推荐系统的一般框架.很明显,推荐方法是整个推荐系统中最核心.最关键的部分,很大程 ...
- Apache Shiro Architecture--官方文档
原文地址:http://shiro.apache.org/architecture.html Apache Shiro's design goals are to simplify applicati ...
- org.apache.hadoop.fs-PositionedReadable
package org.apache.hadoop.fs; import java.io.*; import org.apache.hadoop.fs.*; /** Stream that permi ...
- 使用JS制作一个鼠标可拖的DIV(一)——鼠标拖动
使用 JS 来实现一个可拖动的DIV,主要是使用到以下几个事件: 1.鼠标按下:DIV元素的onmousedown. 2.鼠标按住拖动:document 的 onmousemove 元素. 3.鼠标放 ...