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. 抽象工厂模式( Abstract Factory )

    提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类.解决多产品多等级结构.模式的类图如下: 抽象工厂模式的优点: 易于交换产品系列,由于具体工厂类在一个应用中只需要在初始化的时候出现一 ...

  2. Java网络编程详解

    内容: 1.网络通信协议 2.UDP与TCP 3.UDP通信 4.TCP通信 5.网络编程总结 1.网络通信协议 (1)基本概念 网络:由多台计算机以及外部设备连接起来的一个系统,我们称之为网络 通信 ...

  3. php内存回收机制的学习

    今天朋友去面试,回来问了一下怎么样,结果他说一脸懵逼,看来我们平时还是学习的太少了啊.于是比较好奇,果断问了一下都有哪些问题,朋友说第一个问题就是“描述PHP的垃圾回收机制”,我当时听了也是一脸茫然, ...

  4. 使MySQL查询区分大小写的实现方法

    发布:mdxy-dxy 字体:[增加 减小] 类型:转载 我们在MySQL中使用SELECT语句查询时,可不可以使查询区分大小写?今天从网络上找到了方法,现总结如下.   1.一种方法是可以设置表或行 ...

  5. jdk配置(备份)

    #####set java environment #export JAVA_HOME=/usr/java/jdk1..0_172 #export JRE_HOME=${JAVA_HOME}/jre ...

  6. leetcode415

    public class Solution { public string AddStrings(string num1, string num2) { //判断num1和num2的长度,进行对齐 i ...

  7. mysql 5.7.10使用dbforget Studio 连接异常

    提示:The 'INFORMATION_SCHEMA.SESSION_VARIABLES' feature is disabled; see the documentation for 'show_c ...

  8. 生产者和消费者模式--java设计模式

    生产者和消费者: 就犹如在快餐店点餐一样,有多个打饭的,有不定时的人来买饭,买饭的人从快餐店自动取餐,如果快餐的库存数量达到下限值时,自动启动打饭的,补充盒饭. 通过while循环的方式,传入变量is ...

  9. 基于OpenGL编写一个简易的2D渲染框架-12 重构渲染器-BlockAllocator

    BlockAllocator 的内存管理情况可以用下图表示 整体思路是,先分配一大块内存 Chunk,然后将 Chunk 分割成小块 Block.由于 Block 是链表的一个结点,所以可以通过链表的 ...

  10. UI5-文档-2.4-Node.js-Based开发环境

    用于修改OpenUI5.环境是基于Node.js,用作服务器,具有一个基于Grunt的构建过程.本节提供关于初始设置.开发工作流和测试执行的信息. 常规开发过程: 不需要构建过程,您可以简单地修改任何 ...