ACM篇:POJ 3630 -- Phone Number
来源:互联网 发布:淘宝当季新品怎么设置 编辑:程序博客网 时间:2024/06/04 19:45
对电话号码排序。
如果A是B的前缀,
那么A恰好在B前面一位。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int MAXN = 10000;int n;char s[MAXN+1][10+1];char *ps[MAXN+1];void read_phone(){ scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%s", s[i]); ps[i] = s[i]; }}bool _cmp(char *s, char *t){ return strcmp(s, t) < 0;}bool is_consistant(){ for (int i = 0; i < n - 1; i++) if (!strncmp(ps[i], ps[i+1], strlen(ps[i]))) return false; return true;}int main(){ int T; int kase = 0; scanf("%d", &T); while (++kase <= T) { read_phone(); sort(ps, ps+n, _cmp); printf("%s\n", is_consistant() ? "YES" : "NO"); } return 0;}
0 0
- ACM篇:POJ 3630 -- Phone Number
- ACM POJ 3630 (Phone List)
- ACM篇:POJ 1019--Number Sequence
- 山东省第一届ACM省赛题——Phone Number
- POJ 3630 Phone List
- POJ 3630 Phone List
- poj 3630 Phone List
- poj 3630 Phone List
- POJ 3630 Phone List
- Poj 3630 Phone List
- POJ 3630 Phone List
- poj 3630 Phone List
- poj 3630 phone list
- poj 3630 Phone List
- POJ-3630 Phone List
- POJ 3630 Phone List
- poj 3630(phone list)
- poj 3630 Phone List
- PAT-1043. 输出PATest(满分)
- 【Postman】postman 客户端使用(再也不用翻墙下载,也不用下载谷歌浏览器或火狐浏览器)
- Sort Colors
- Java ConcurrentModificationException异常原因和解决方法
- assets中放入含中文文件名导致编译错误
- ACM篇:POJ 3630 -- Phone Number
- recyclerview之item点击事件监听
- The Caret Package
- 快速排序
- 【ROS】移动机器人导航仿真(3)——定位(amcl)和路径规划(move_base)
- MySQL Group Replication 介绍
- Git命令详解(下)
- Centos7安装完提示Initial setup of CentOS Linux 7 (core)
- UEditor在项目中的应用