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之函数——基础篇

    函数 函数,在BASIC中,叫subroutine(子过程或子程序),在Pascal中叫做procedure(过程)和function,在C中只有function,在Java中叫method. 定义: ...

  2. OpenACC Julia 图形

    ▶ 书上的代码,逐步优化绘制 Julia 图形的代码 ● 无并行优化(手动优化了变量等) #include <stdio.h> #include <stdlib.h> #inc ...

  3. smokeping配置方法

    smokeping配置加Nginx https://lala.im/2821.html  (不完整)

  4. 3. HashMap和JSONObject用法

    <%@page import="net.sf.json.JSONObject"%><%@page import="java.util.List" ...

  5. js1:根据标签的Id获取value值

    例子:<input id="startDate" name="startDate" value="2015-09-14" class= ...

  6. VB 调用动态链接库

    作为一种简单易用的Windows开发环境,Visual Basic从一推出就受到了广大编程人员的欢迎.它使 程序员不必再直接面对纷繁复杂的Windows消息,而可以将精力主要集中在程序功能的实现上,大 ...

  7. 五种方法实现Java的Singleton单例模式

    面试的时候经常会问到Java的单例模式,这道题能很好的考察候选人对知识点的理解程度.单例模式要求在系统运行时,只存在唯一的一个实例对象. 下面我们来详细剖析一下其中的关键知识点,并介绍五种实现方法,以 ...

  8. 泛型集合与DataSet相互转换

    一.泛型转DataSet /// <summary> /// 泛型集合转换DataSet /// </summary> /// <typeparam name=" ...

  9. 判断一个对象是否为真 __nonzero__ 方法和 __len__方法

    class A(): def __nonzero__(self): # 判断 一个对象是否为空,先查看该方法的返回值 return 1 def __len__(self): # 如果没有上一个方法,那 ...

  10. neo4j 学习-2

    Neo4j 查询例句 MATCH (john {name: 'John'})-[:friend]->()-[:friend]->(fof) RETURN john.name, fof.na ...