【Educational Codeforces Round 2A】【模拟】Extract Numbers 分离数串和字符串

来源:互联网 发布:广州市失独数据 编辑:程序博客网 时间:2024/06/06 07:08
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 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 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", "".

//http://blog.csdn.net/snowy_smile#include<stdio.h>#include<string.h>#include<ctype.h>#include<math.h>#include<iostream>#include<string>#include<set>#include<map>#include<vector>#include<queue>#include<bitset>#include<algorithm>#include<time.h>using namespace std;void fre(){freopen("c://test//input.in","r",stdin);freopen("c://test//output.out","w",stdout);}#define MS(x,y) memset(x,y,sizeof(x))#define MC(x,y) memcpy(x,y,sizeof(x))#define MP(x,y) make_pair(x,y)#define ls o<<1#define rs o<<1|1typedef long long LL;typedef unsigned long long UL;typedef unsigned int UI;template <class T> inline void gmax(T &a,T b){if(b>a)a=b;}template <class T> inline void gmin(T &a,T b){if(b<a)a=b;}const int N=1e5+10,M=0,Z=1e9+7,ms63=1061109567;char s[N];string a,b;int main(){while(~scanf("%s",s)){int l=strlen(s);s[l]=';';int p=0;bool flag=0;a="";int numa=0;b="";int numb=0;for(int i=0;i<=l;++i){if(s[i]==','||s[i]==';'){s[i]=0;if(!flag&&s[p]!=0){if(++numa==1)a+=s+p;else {a+=",";a+=s+p;}}else{if(++numb==1)b+=s+p;else {b+=",";b+=s+p;}}p=i+1;flag=0;}else if(!isdigit(s[i]))flag=1;else if( (i==0||s[i-1]==0) && s[i]=='0'&&isdigit(s[i+1]))flag=1;}if(numa==0)a="-";else a='"'+a+'"';if(numb==0)b="-";else b='"'+b+'"';cout<<a<<endl<<b<<endl;}return 0;}/*【题意】若干个字符串在一行。字符串有数串(无前导零)和其他串,之间用','或';'分隔。让你把两种类型的串在两行分别输出。【类型】模拟【分析】直接模拟即可。1,数串的判定除了数字全为digit外,还要求没有前导零。2,可以用末尾赋值为0的方法做串赋值串合并操作。【时间复杂度&&优化】O(|s|)*/


0 0