Digits Are Not Just Characters

Time Limit: 2 Sec Memory Limit: 256 Mb
题目链接http://acm.csu.edu.cn:20080/csuoj/problemset/problem?pid=2280

Description

Mr. Manuel Majorana Minore made a number of files with numbers in their names. He wants to have a list of the files, but the file listing command commonly used lists them in an order different from what he prefers, interpreting digit sequences in them as ASCII code sequences, not as numbers. For example, the files file10, file20 and file3 are listed in this order.

Write a program which decides the orders of file names interpreting digit sequences as numeric values.

Each file name consists of uppercase letters (from ‘A’ to ‘Z’), lowercase letters (from ‘a’ to ‘z’), and digits (from ‘0’ to ‘9’).

A file name is looked upon as a sequence of items, each being either a letter or a number. Each single uppercase or lowercase letter forms a letter item. Each consecutive sequence of digits forms a number item.

Two item are ordered as follows.

Number items come before letter items.
Two letter items are ordered by their ASCII codes.
Two number items are ordered by their values when interpreted as decimal numbers.
Two file names are compared item by item, starting from the top, and the order of the first different corresponding items decides the order of the file names. If one of them, say A, has more items than the other, B, and all the items of B are the same as the corresponding items of A, BB should come before.

For example, three file names in Sample Input 1, file10, file20, and file3 all start with the same sequence of four letter items f, i, l, and e, followed by a number item, 10, 20, and 3, respectively. Comparing numeric values of these number items, they are ordered as file3 < file10 <file20.

Input

The input consists of a single test case of the following format.
n
s0
s1
.
.
sn
The integer n in the first line gives the number of file names s1 through sn to be compared with the file name given in the next line(s0).

Here,n satisfies 1 ≤ n ≤ 1000

The following n + 1 lines are file names,s0 through sn ,one in each line. They have at least one and no more than nine characters. Each of the characters is either an uppercase letter, a lowercase letter, or a digit.

Sequences of digits in the file names never start with a digit zero (0).

Output

For each of the file names, s1 through sn, output one line with a character indicating whether it should come before s0 or not. The character should be “-” if it is to be listed before s0; otherwise, it should be “+”, including cases where two names are identical.

Sample Input

11
X52Y
X
X5
X52
X52Y
X52Y6
32
ABC
XYZ
x51y
X8Y
X222

Sample Output


题目大意:给你一个模板和n个字符串,对于每个字符串输出‘-’如果该字符串应该排在模板串的前面,否则输出‘+’。排序规则:
1.数字总是排在字母的前面。
2.字母按ASCll排序。
3.数字按照其值的大小排序:对于X52Y与X8Y,由于52>8所以X8Y应该排在X52Y前面。。。
题目明白了接下来就是大模拟了,尽量简化:

#include <cstdio>
#include <cstring>
#define debug(n) printf("%d ",n)
using namespace std;
char s[1020][15];
int a[15],b[15];
int nz(char ch) {if ((ch>='a' && ch<='z') || (ch>='A' && ch<='Z')) return 0;return 1;
}
int rd(int x)
{int s=0;while (x>0){x/=10;s++;}return s;
}
int main() {int n;scanf ("%d",&n);for (int i=0; i<=n; i++) {scanf ("%s",s[i]);}int len=strlen(s[0]);for (int i=0; i<len; i++) {int k=i;if (nz(s[0][i])) {while (nz(s[0][i]) && i<len) a[k]=a[k]*10+s[0][i]-'0',i++;}}for (int i=1; i<=n; i++) {int mark=0;int len2=strlen(s[i]);int head=0;memset(b,0,sizeof(b));for (int j=0; j<len2; j++) {int k=j;if (nz(s[i][j])) {while (nz(s[i][j]) && j<len2) b[k]=b[k]*10+s[i][j]-'0',j++;}}while (head<len && head<len2) {int lin=nz(s[0][head]),ai=nz(s[i][head]);if (lin<ai) {printf ("-\n");mark=1;break;} else if (lin>ai) {printf ("+\n");mark=1;break;} else {if (a[head]&&b[head]){if (a[head]>b[head]) {printf ("-\n");mark=1;break;}else if (a[head]<b[head]) {printf ("+\n");mark=1;break;}head+=rd(a[head]);continue;}else if (s[0][head]>s[i][head]) {printf ("-\n");mark=1;break;} else if (s[0][head]<s[i][head]) {printf ("+\n");mark=1;break;}}head++;}if (!mark) {if (len2<len) printf ("-\n");else printf ("+\n");}}return 0;
}

A.Digits Are Not Just Characters---2018横滨区域赛(大模拟)相关推荐

  1. 2018亚洲区域赛焦作站参赛总结

    2018年11月26日,我们参加了ACM焦作站的区域赛,第188名,差14名获得铜奖,些许遗憾.下面从赛前准备,比赛过程,赛后反思和规划三方面总结一下. 赛前准备,因为11.3是青岛站的区域赛,所以准 ...

  2. 2018南京区域赛 J-Prime Game

    完全没有头绪 听完队友讲的我还是楞了好半天菜慢慢理解.我好菜啊 首先要弄懂题目的意思,转换一下题意就是求每个素因子出现区间的次数.区间长度最短为1.我们分析,第一个数的因子会影响1* n个区间(暂时不 ...

  3. 伊朗 2018 ICPC区域赛 A : Iranian ChamPions Cup

    题目描述 The Iranian ChamPions Cup (ICPC), the most prestigious football league in Iran, is reaching its ...

  4. 2018北京区域赛总结

    因为这次北京之行要花费四五天,临行前,我将所有课程的作业都做完了,甚至连回来要上的课的都提前准备了.万万没想到,jsp老师突然说要期中考,这令我心中有些烦躁,有点担心学业会被这次比赛搞砸.犹豫了一下, ...

  5. 2018年区域赛总结

    今年区域赛,一铁一铜告终 第一站青岛站,打铁.难过是难过,但是变强的想法就更加强烈,同时也更加深刻的体会到了正式赛与区域赛还是在各个方面存在差别,平常应该更规范的要求自己. 热身赛因为只有一个人,虽然 ...

  6. 2020牛客国庆集训派对day4 Digits Are Not Just Characters

    Digits Are Not Just Characters 题意: 比较大小,如果比目标字符串大输出"+",相等也输出"+",小则输出"-" ...

  7. 2018年全球十大新兴技术:细胞植入人体、营养人造肉……你想试试吗?

    来源:光明日报 摘要:在不久的将来,技术革新将如何改变我们的生活?人工智能将大幅提升新药物和新材料的开发速度:新型诊断工具将打造更先进的个性化医疗:如果你生病了,医生将可以在你体内植入活细胞,用这些& ...

  8. MIT发布2018年全球10大突破性技术!

    来源: 数字化企业 作为全球最为著名的技术榜单之一,<麻省理工科技评论>全球十大突破性技术具备极大的全球影响力和权威性,至今已经举办了18年.每年上榜的技术突破,有的已经在现实中得以应用, ...

  9. 美媒评2018年全球十大突破性技术:AI和人工胚胎上榜

    来源:新浪科技 作者:邱越 斯眉 美国<麻省理工科技评论>本周刊文,列出了2018年的10大科技突破.今年入选的技术包括人工智能技术"生成对抗网络"(GAN).人工胚胎 ...

最新文章

  1. web app升级—带进度条的App自动更新
  2. Qt开发环境的下载地址
  3. ML之NB:基于NB朴素贝叶斯算法训练20类新闻文本数据集进行多分类预测
  4. Maven之(二)Maven生命周期
  5. java实现沙箱测试环境支付宝支付(demo)和整合微信支付和支付宝支付到springmvc+spring+mybatis环境全过程(支付宝和微信支付)
  6. knn人脸识别判断_测试使用K-最近邻(kNN)算法的30个问题
  7. anddroid悬浮窗的手机QQ后台清理不掉的秘密
  8. 招聘 | 大疆算法类未来大咖招聘
  9. 大数据之-Hadoop_推荐系统框架图---大数据之hadoop工作笔记0015
  10. 关闭SSMS的事务自动提交,改为手动提交
  11. 简单易用的android 热修复
  12. 华为eNSP-动态路由实验
  13. 基于 USB 传输的针式打印机驱动程序开发
  14. php yar2,[原]PHP-yar拓展源码解读二-protocol篇
  15. Google着手与 Open AI 合作预防人工智能暴走
  16. codeforces1146G Zoning Restrictions
  17. html颜色趋势,跟上色彩潮流!带你展望2015年的网页设计配色趋势
  18. 关于Java反射获取静态属性值的方式
  19. go 服务接入短信验证码功能(对接阿里云平台)
  20. 固体物理 2022.10.7 一维单原子链 结束

热门文章

  1. tcpcopy mysql_tcpcopy+mysql压力测试
  2. 蚂蚁金服技术出海,“暖科技”亮相世界顶尖计算机视觉CVPR大会
  3. 熊海CMS网站SQL注入、XSS攻击、cookie篡改
  4. 有这样的老婆,真舒服!
  5. String 中 split 方法的效率问题
  6. Use KLEE to Test GNU Coreutils
  7. 车友须知,关于汽车过户的时间问题。
  8. uniapp中上传图片(拍摄)和预览图片(图例和示例代码)
  9. 记2020年7月5日深圳福田凤凰楼嵌入式/物联网博客-公众号大佬面基聚会
  10. 微信学习小组 打卡群 云自习