Extract Numbers
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

You are given string s. Let's call word any largest sequence of consecutive symbols without symbols ',' (comma) and ';' (semicolon). For example, there are four words in string "aba,123;1a;0": "aba", "123", "1a", "0". A word can be empty: for example, the string s=";;" contains three empty words separated by ';'.

You should find all words in the given string that are nonnegative INTEGER numbers without leading zeroes and build by them new string a. String a should contain all words that are numbers separating them by ',' (the order of numbers should remain the same as in the string s). By all other words you should build string b in the same way (the order of numbers should remain the same as in the string s).

Here strings "101", "0" are INTEGER numbers, but "01" and "1.0" are not.

For example, for the string aba,123;1a;0 the string a would be equal to "123,0" and string b would be equal to "aba,1a".

Input

The only line of input contains the string s (1 ≤ |s| ≤ 105). The string contains only symbols '.' (ASCII 46), ',' (ASCII 44), ';' (ASCII 59), digits, lowercase and uppercase latin letters.

Output

Print the string a to the first line and string b to the second line. Each string should be surrounded by quotes (ASCII 34).

If there are no words that are numbers print dash (ASCII 45) on the first line. If all wordsare numbers print dash on the second line.

Examples
input

Copy
aba,123;1a;0
output

Copy
"123,0"
"aba,1a"
input

Copy
1;;01,a0,
output

Copy
"1"
",01,a0,"
input

Copy
1
output

Copy
"1"
-
input

Copy
a
output

Copy
-
"a"
Note

In the second example the string s contains five words: "1", "", "01", "a0", "".

题意:

给你一个字符串,以‘,’或‘;’来分割单词,并让你给单词分类,a类放没有前导0的非负整数单词,b类放除a类以外的单词,如果某个类为空则输出'-',否则用引号""括起答案输出

思路:

现在我们以单词结尾的','或‘;’来进行分割,但一开始输入的字符串如果末尾为‘,’或‘;’,则还应统计一个空格,但这个空格末尾没有','或';'来给我判断,所以为了统一,我们在结尾加上';'
接着要统计a类和b类单词个数
如果到了一个单词的结束分割符','或';',则把则个字符标记为分割符,并判断要把当前单词加入a类还是b类,默认当前单词是a类,如果当前单词存在一个非整数位或有前导零则当前单词属于b类
接着看怎么添加单词,如果当前是第一个加进的单词,就不用在前面加','分割,直接添加当前单词,否则先添一个','再添如当前单词
输出时如果某个类为空则输出'-',否则用引号""括起答案输出

 #include<bits/stdc++.h>
using namespace std;
const int amn=1e5+;
char s[amn],a[amn],b[amn],tmp[amn];
struct index{
int st,ed;
}idx[amn];
int main(){
ios::sync_with_stdio();
cin>>s;
int len=strlen(s);
s[len]=';'; ///现在我们以单词结尾的','或‘;’来进行分割,但一开始输入的字符串如果末尾为‘,’或‘;’,则还应统计一个空格,但这个空格末尾没有','或';'来给我判断,所以为了统一,我们在结尾加上';'
int st=,ed=,tp=;
int atp=,btp=,f=,it=; ///atp和btp分别是统计a类和b类单词个数
for(int i=;i<=len;i++){
if(s[i]==','||s[i]==';'){ ///到了一个单词的结束
s[i]=;
if(f&&s[it]){
if(++atp==)strcat(a,s+it); ///如果当前是第一个加进的单词,就不用在前面加','分割,直接添加当前单词
else strcat(a,","),strcat(a,s+it); ///否则先添一个','再添如当前单词
}
else{
if(++btp==)strcat(b,s+it);
else strcat(b,","),strcat(b,s+it);
}
it=i+;
f=; ///默认是符合条件的非负整数
}
else if(s[i]<''||s[i]>''||((i==||s[i-]==)&&s[i]==''&&(s[i+]>=''&&s[i+]<='')))f=; ///如果当前单词存在一个非整数位或有前导零则当前单词属于b类
}
int alen=strlen(a),blen=strlen(b);
if(atp){
printf("\"");
for(int i=;i<alen;i++){
printf("%c",a[i]);
}
printf("\"\n");
}
else{ ///如果没单词,则输出-下面同理
printf("-\n");
}
if(btp){
printf("\"");
for(int i=;i<blen;i++){
printf("%c",b[i]);
}
printf("\"\n");
}
else{
printf("-\n");
}
}
/***
给你一个字符串,以‘,’或‘;’来分割单词,并让你给单词分类,a类放没有前导0的非负整数单词,b类放除a类以外的单词,如果某个类为空则输出'-',否则用引号""括起答案输出
现在我们以单词结尾的','或‘;’来进行分割,但一开始输入的字符串如果末尾为‘,’或‘;’,则还应统计一个空格,但这个空格末尾没有','或';'来给我判断,所以为了统一,我们在结尾加上';'
接着要统计a类和b类单词个数
如果到了一个单词的结束分割符','或';',则把则个字符标记为分割符,并判断要把当前单词加入a类还是b类,默认当前单词是a类,如果当前单词存在一个非整数位或有前导零则当前单词属于b类
接着看怎么添加单词,如果当前是第一个加进的单词,就不用在前面加','分割,直接添加当前单词,否则先添一个','再添如当前单词
输出时如果某个类为空则输出'-',否则用引号""括起答案输出
***/

[模拟]Educational Codeforces Round 2A Extract Numbers的更多相关文章

  1. Educational Codeforces Round 32

    http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...

  2. [Educational Codeforces Round 16]C. Magic Odd Square

    [Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different number ...

  3. Educational Codeforces Round 37

    Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...

  4. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  5. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...

  6. Educational Codeforces Round 63 (Rated for Div. 2) 题解

    Educational Codeforces Round 63 (Rated for Div. 2)题解 题目链接 A. Reverse a Substring 给出一个字符串,现在可以对这个字符串进 ...

  7. Educational Codeforces Round 58 (Rated for Div. 2) 题解

    Educational Codeforces Round 58 (Rated for Div. 2)  题目总链接:https://codeforces.com/contest/1101 A. Min ...

  8. Educational Codeforces Round 35 A. Nearest Minimums【预处理】

    [题目链接]: Educational Codeforces Round 35 (Rated for Div. 2) A. Nearest Minimums time limit per test 2 ...

  9. Educational Codeforces Round 26

    Educational Codeforces Round 26 困到不行的场,等着中午显示器到了就可以美滋滋了 A. Text Volume time limit per test 1 second ...

随机推荐

  1. SQL语法练习(一)

    查询学习课程"python"比课程 "java" 成绩高的学生的学号;– 思路:– 获取所有有python课程的人(学号,成绩) - 临时表– 获取所有有jav ...

  2. Lambda表达式和函数试接口的最佳实践 · LiangYongrui's Studio

    1.概述 本文主要深入研究java 8中的函数式接口和Lambda表达式,并介绍最佳实践. 2.使用标准的函数式接口 包java.util.function中的函数是接口已经可以满足大部分的java开 ...

  3. JAVA补0--->String.format()的使用

    详细地址:http://blog.csdn.net/lonely_fireworks/article/details/7962171/ 标    志 说    明 示    例 结    果 + 为正 ...

  4. 联想拯救者y7000使用体验

    前言 我以前的电脑是在电商平台买的二手电脑,期间觉得软件的运行速度慢,又在网上买了一个128G的固态硬盘安装上.就从大一到大四上学期这么使用了三年半的时间.因为自己需要运行一些吃内存的软件,而我的这个 ...

  5. 难道同事:Java 方法调用到底是传值还是传引用

    Java 方法调用中的参数是值传递还是引用传递呢?相信每个做开发的同学都碰到过传这个问题,不光是做 Java 的同学,用 C#.Python 开发的同学同样肯定遇到过这个问题,而且很有可能不止一次. ...

  6. MyBatis配置文件中config与mapper的约束

    本文链接:https://blog.csdn.net/gaoxin_gx/article/details/100183455 Config的约束: <?xml version="1.0 ...

  7. preload & prefetch

    原文地址在 我的笔记里,觉得还行就给个 star 吧:) 关于 preload 和 prefetch 早有耳闻,知道它们可以优化页面加载速度,然具体情况却了解不多.搜索了相关的资料后对其有了些认识,在 ...

  8. 移动端轮播图实现方法(dGun.js)

    本文章介绍在移动端无缝隙轮播图实现的原理,这个轮子比较简单,但可以方便刚刚入门的同学参考.最终效果是在移动端无缝隙无限滑动,可以自定义轮播的速度.支持手势左右滑动.最后会放上源码. HTML部分 &l ...

  9. 【线上测试之后的应用】基于MySQL+MHA+Haproxy构建高可用负载均衡数据库集群(详解)

    这里我们先介绍一下MHA是什么,其次就是它的应用与测试,同时为了大家呈现了数据备份案例,最后总结了使用情况以及注意事项和解决办法 一.MHA 概述 MHA(Master High Availabili ...

  10. 前端开发--nginx番外篇

    Centos7下Nginx开发使用(背景: 阿里云ECS Centos7) 安装和启动 安装教程 Centos7安装Nginx实战 需要主意的如下: 文中第四步 4.配置编译参数命令:(可以使用./c ...