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. 使用CMQ和SCF实现邮件发送

    准备腾讯云 API 调用工具 使用 API 命令行工具来管理和运行无服务器云函数(SCF),下面就先来安装配置该工具. 安装 Python 和 PIP Python 环境是腾讯云命令行工具运行时的必要 ...

  2. python文件操作与字符编码

    知识内容: 1.文件对象与文件处理流程 2.基本操作 3.上下文管理 4.文件的修改与文件内光标的移动 5.字符编码 一.文件对象与文件处理流程 1.文件对象 (1)文件分类 按文件中数据的组织形式可 ...

  3. 如何提取一个转录本的3'UTR区域的序列

    庐州月光 如何提取一个转录本的3'UTR区域的序列 在做microRNA 和 mRNA 相互作用预测的时候,大家都知道microRNA 作用的靶点是位于mRNA 的3'UTR取,所以只需要提取mRNA ...

  4. 使用再生龙Clonezilla备份还原Linux系统

    一位老哥推荐给我的,产地是祖国宝岛台湾,实测效果非常好,解决了我的一个大问题. 为了减少篇幅,方便阅读,把备份还原的过程单独写一篇随笔. 官网简介:http://clonezilla.nchc.org ...

  5. 查windows系统开关机记录

    https://blog.csdn.net/dufufd/article/details/53316079 者是按下"开始菜单"-"程序"-"管理工具 ...

  6. sqoop1 与sqoop2的对比

    Sqoop是一款开源的工具,主要用于在Hadoop和传统的数据库(mysql.postgresql等)进行数据的传递,可以将一个关系型数据库(例如:MySQL.Oracle.Postgres等)中的数 ...

  7. 线程安全计算 AtomicLong

    一般如果我们自己写一个计数器方法,需要考虑线程安全问题,尤其高并发访问的时候. AtomicLong 已处理并发问题,直接使用.java.util.concurrent.atomic包提供多种线程安全 ...

  8. 使用MATPLOTLIB 制图(小图)

    import numpy as np import pandas as pd import matplotlib.pyplot as plt data = pd.read_csv('D:\\myfil ...

  9. LiveBinding应用 dataBind 数据绑定

    http://blog.csdn.net/embarcaderochina/article/details/50352193 firemonkey grid/listview dataBind,数据绑 ...

  10. SQL Server 2005 无法连接到WMI提供程序 无法执行 SQL Server 系统配置检查器

    无法连接到WMI提供程序.你没有权限或者该服务器无法访问/cannot connect to WMI provider. You do not have permission or the--由于计算 ...