博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
<cf>Sysadmin Bob
阅读量:6850 次
发布时间:2019-06-26

本文共 2668 字,大约阅读时间需要 8 分钟。

B. Sysadmin Bob
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Email address in Berland is a string of the form A@B, where A and B are arbitrary strings consisting of small Latin letters.

Bob is a system administrator in «Bersoft» company. He keeps a list of email addresses of the company's staff. This list is as a large string, where all addresses are written in arbitrary order, separated by commas. The same address can be written more than once.

Suddenly, because of unknown reasons, all commas in Bob's list disappeared. Now Bob has a string, where all addresses are written one after another without any separators, and there is impossible to determine, where the boundaries between addresses are. Unfortunately, on the same day his chief asked him to bring the initial list of addresses. Now Bob wants to disjoin addresses in some valid way. Help him to do that.

Input

The first line contains the list of addresses without separators. The length of this string is between 1and 200, inclusive. The string consists only from small Latin letters and characters «@».

Output

If there is no list of the valid (according to the Berland rules) email addresses such that after removing all commas it coincides with the given string, output No solution. In the other case, output the list. The same address can be written in this list more than once. If there are several solutions, output any of them.

Sample test(s)
input
a@aa@a
output
a@a,a@a
input
a@a@a
output
No solution
input
@aa@a
output
No solution

AC code:

#include 
#include
#include
using namespace std;int main(){ char s[202]; char c; // int cnt1=0,cnt2=0;//cnt1、cnt2分别记录字母和@的个数 queue
pos;//记录出现@处的下标 bool OK=1;//判断是否能还原 int len,i,j; for(len=0,i=0;scanf("%c",&c)!=EOF;len++) {//cout<<1; if(c=='\n' || c=='\r') { s[len]='\0'; break; } else if(c=='@') { //两个@间距不足两位,注意要在pos不为空时才执行。 if(!pos.empty() && len-pos.back()<3) {//cout<<"*"; OK=0; while(scanf("%c",&c) && !(c=='\n' || c=='\r')){} break; } s[len]=c; pos.push(len); } else { s[len]=c; //cnt1++; } } if(OK) { //如果不存在@ or 不存在字母 or 首字符是@ or 末字符是@ if(pos.empty() || !(len-pos.size()) || s[len-1]=='@' || s[0]=='@') { OK=0; } else for(i=0;s[i]!='\0';) { if(pos.size()>1) { for(;i

转载地址:http://weeul.baihongyu.com/

你可能感兴趣的文章
SQL Server 的事务和锁(一)
查看>>
label标签跳出循环
查看>>
linux分享二:Linux如何修改字符集
查看>>
Eclipse 配置SSH 详解
查看>>
你的认真在他们看来只是一个玩笑
查看>>
SDUT OJ 2783 小P寻宝记
查看>>
数据库设计三大范式
查看>>
用地图和提示的导航和定位--15
查看>>
编程教训
查看>>
请MVC5 WebApi2 支持OData协议查询
查看>>
ZeroMQ(java)中监控Socket
查看>>
06- Shell脚本学习--其它
查看>>
Spring mvc json null
查看>>
【web JSP basePath】basePath的含义
查看>>
linux下时间同步的两种方法分享
查看>>
Format
查看>>
springboot自定义常量配置
查看>>
FastFDFS_Jave客户端调用(亲测可用)
查看>>
联想Y50耳机插入耳机孔后没有声音解决办法
查看>>
ImageSharp .NET Core跨平台图形处理库
查看>>