A. 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 strings=";;" 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 strings).

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 words are numbers print dash on the second line.

Sample test(s)
input
aba,123;1a;0
output
"123,0"
"aba,1a"
input
1;;01,a0,
output
"1"
",01,a0,"
input
1
output
"1"
-
input
a
output
-
"a"
Note

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

题意:有一个仅包含 '.' , ',' , ';' 大小写字母,数字的字符串s  (1 ≤ |s| ≤ 105)。 ',' 和 ';'为分隔符。a字符串是不为0开头的纯数字,其余的均为b字符串。空的也为b中的。具体的看样例和note

思路:暴力一遍来判断,但是在字符串的前面和后面均加一个',',这样可以更加方便判断特殊情况。

#include<bits/stdc++.h>
using namespace std;
char s[];
char a[],b[];
int count1[],count2[];
int main()
{
cin>>s;
int i,j,n=,m=,sign,flag,len=strlen(s);
sign=-;
s[len]=';';
memset(count1,,sizeof(count1));
memset(count2,,sizeof(count2));
for(i=; i<=len; i++)
{
if(s[i]==','||s[i]==';')
{ if(sign+==i)
{
b[m++]='*';
count2[m-]=;
}
else
{
flag=;
if(s[sign+]==''&&(sign+==i)) flag=;
else
{
if(s[sign+]<=''&&s[sign+]>='') flag=;
if(flag==)
{
for(j=sign+; j<i; j++)
{
if(!(s[j]<=''&&s[j]>='')) break;
}
if(j<i) flag=;
else flag=;
}
}
if(flag==)
{
for(j=sign+; j<i; j++)
b[m++]=s[j];
count2[m-]=;
}
else
{
for(j=sign+; j<i; j++)
a[n++]=s[j];
count1[n-]=;
}
}
sign=i;
}
}
if(n==) cout<<"-"<<endl;
else
{
cout<<"\"";
for(i=; i<n; i++)
{
cout<<a[i];
if(count1[i]==&&(i<n-)) cout<<",";
}
cout<<"\""<<endl;
} if(m==) cout<<"-"<<endl;
else
{
cout<<"\"";
for(i=; i<m; i++)
{
if(b[i]=='*');
else cout<<b[i];
if(count2[i]==&&(i<m-)) cout<<",";
}
cout<<"\""<<endl;
}
return ;
}

Codeforces 600A. Extract Numbers 模拟的更多相关文章

  1. codeforces 600A Extract Numbers

    模拟题,意思是一个字符串,单词直接用','或';'来分割,可以为空,把不含前导0的整数和其他单词分别放入A和B.按照一定格式输出. 没有用stl的习惯.维护两个下标i,j,表示开区间(i,j),两段补 ...

  2. Educational Codeforces Round 2 A. Extract Numbers 模拟题

    A. Extract Numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/600/pr ...

  3. codeforce 600A - Extract Numbers

    学习string #include <bits/stdc++.h> #define eps 1e-8 #define M_PI 3.141592653589793 ; using name ...

  4. [模拟]Educational Codeforces Round 2A Extract Numbers

    Extract Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard inp ...

  5. CodeForces 55D "Beautiful numbers"(数位DP+离散化处理)

    传送门 参考资料: [1]:CodeForces 55D Beautiful numbers(数位dp&&离散化) 我的理解: 起初,我先定义一个三维数组 dp[ i ][ j ][ ...

  6. Codeforces 878 E. Numbers on the blackboard

    Codeforces 878 E. Numbers on the blackboard 解题思路 有一种最优策略是每次选择最后面一个大于等于 \(0\) 的元素进行合并,这样做完以后相当于给这个元素乘 ...

  7. Codeforces 55D. Beautiful numbers(数位DP,离散化)

    Codeforces 55D. Beautiful numbers 题意 求[L,R]区间内有多少个数满足:该数能被其每一位数字都整除(如12,24,15等). 思路 一开始以为是数位DP的水题,觉得 ...

  8. [codeforces]Page Numbers <模拟>

    描述: «Bersoft» company is working on a new version of its most popular text editor — Bord 2010. Bord, ...

  9. Educational Codeforces Round 2 A. Extract Numbers

    打开题目链接 题意:输入一个字符串,用,或:分隔输出字符串和整数(不含前导0和浮点数) ACcode: #include <iostream> #include <cstdio> ...

随机推荐

  1. python pip使用报错:Fatal error in launcher: Unable to create process using '"'

    在一个系统中共存Python2.python3的时候,pip.pip2.pip3使用的时候会报错: c:\Python35\Scripts>pip3Fatal error in launcher ...

  2. python3解析XML文件

    软硬件环境 Ubuntu 15.10 32bit Python 3.5.1 PyQt 5.5.1 前言 Python解析XML的方法挺多,本文主要是利用ElementTree来完成. 实例讲解 解析X ...

  3. 关联github, 添加gitignore 规则

    1. 新建Maven项目 2. 新建github repository 3. 执行命令 echo "# se" >> README.md git init git ad ...

  4. ABAP-ALV详解

    OO ALV: https://www.cnblogs.com/jiangzhengjun/p/4291373.html https://www.cnblogs.com/jiangzhengjun/p ...

  5. Java Socket通信实例

    一.简单的客户端与服务器一对一连接: Socket通信的步骤: 1.创建ServerSocket和Socket 2.打开连接到Scket的输入/输出流 3.按照协议对Socket进行读/写操作 4.关 ...

  6. php, postgresql 安装

    sudo yum install postgresql84-server postgresql84-contrib ubuntu下面安装的问题解决: Postgresql installation o ...

  7. ubuntu sudo apt-get upgrade 和 sudo apt-get dist-upgrade区别

    sudo apt-get upgrade: 不会对系统产生重大的影响,可以在任何时候运行. sudo apt-get dist-upgrade: 涉及核心的升级,通常会对系统功能产生实际的影响,可能在 ...

  8. 管道限流利器pv

    pv 是什么 可不是 page view,是pipe viewer,管道偷窥器的缩写.这个东西的源站点在google code上,需要的话可以访问pv 的官网 . 这个东西的官方手册页(man pv或 ...

  9. 疯狂JAVA——第八章 java集合

    集合类主要负责保存.盛装其他数据,因此集合类也被称为容器类. 数组元素既可以是基本类型的值,也可以是对象(实际上是保存的对象的引用): 集合里只能保存对象.

  10. 常用mysql text 类型,varchar最大长度

    MySQL 3种text类型的最大长度如下: TEXT 65,535 bytes ~64kb MEDIUMTEXT 16,777,215 bytes ~16Mb LONGTEXT 4,294,967, ...