CF412E.E-mail Addresses
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
One of the most important products of the R1 company is a popular @r1.com mail service. The R1 mailboxes receive and send millions of emails every day.
Today, the online news thundered with terrible information. The R1 database crashed and almost no data could be saved except for one big string. The developers assume that the string contains the letters of some users of the R1 mail. Recovering letters is a tedious mostly manual work. So before you start this process, it was decided to estimate the difficulty of recovering. Namely, we need to calculate the number of different substrings of the saved string that form correct e-mail addresses.
We assume that valid addresses are only the e-mail addresses which meet the following criteria:
- the address should begin with a non-empty sequence of letters, numbers, characters '_', starting with a letter;
- then must go character '@';
- then must go a non-empty sequence of letters or numbers;
- then must go character '.';
- the address must end with a non-empty sequence of letters.
You got lucky again and the job was entrusted to you! Please note that the substring is several consecutive characters in a string. Two substrings, one consisting of the characters of the string with numbers _l_1, _l_1 + 1, _l_1 + 2, ..., _r_1 and the other one consisting of the characters of the string with numbers _l_2, _l_2 + 1, _l_2 + 2, ..., _r_2, are considered distinct if _l_1 ≠ _l_2 or _r_1 ≠ _r_2.
R1 公司最重要的产品之一是广受欢迎的 @r1.com 邮件服务。R1 的邮箱每天接收和发送数百万封电子邮件。
今天,网络新闻头条传来了令人震惊的坏消息:R1 数据库崩溃了,几乎没有任何数据得以保存,仅剩下一个很长的字符串。开发人员推测该字符串中包含了部分 R1 邮箱用户的邮箱地址字符。而从该字符串中恢复出原始邮箱地址是一项繁琐且主要依赖人工的工作。因此,在正式开始恢复工作之前,决定先评估恢复工作的难度——具体而言,需要计算该保存下来的字符串中,有多少个互不相同的子串能够构成合法的电子邮件地址。
我们定义一个合法的邮箱地址需同时满足以下所有条件:
- 地址必须以一个非空的字符序列开头,该序列仅由字母、数字或下划线
'_'组成,且首字符必须为字母; - 其后必须紧跟一个字符
'@'; - 其后必须是一个非空的、仅由字母或数字组成的字符序列;
- 其后必须紧跟一个字符
'.'; - 地址必须以一个非空的、仅由字母组成的字符序列结尾。
你又一次幸运地被委以这项任务!请注意:子串指的是字符串中若干连续的字符。对于两个子串,若其起始位置与结束位置不同(即:一个子串对应原字符串中下标为 l1,l1+1,l1+2,…,r1 的字符,另一个子串对应下标为 l2,l2+1,l2+2,…,r2 的字符),则只要 l1=l2 或 r1=r2,就认为它们是不同的子串。
输入格式
The first and the only line contains the sequence of characters _s_1_s_2... s__n (1 ≤ n ≤ 106) — the saved string. It is guaranteed that the given string contains only small English letters, digits and characters '.', '_', '@'.
第一行且唯一一行包含字符序列 s1s2…sn(1 ≤ n ≤ 106)——即保存的字符串。保证给定字符串仅包含小写英文字母、数字以及字符 .、_、@。
输出格式
Print in a single line the number of substrings that are valid e-mail addresses.
在一行中输出是有效电子邮件地址的子字符串的数量。
输入输出样例
输入#1
[email protected]
输出#1
18
输入#2
[email protected]@[email protected]
输出#2
8
输入#3
[email protected]
输出#3
1
输入#4
.asd123__..@
输出#4
0
说明/提示
In the first test case all the substrings that are correct e-mail addresses begin from one of the letters of the word agapov and end in one of the letters of the word com.
In the second test case note that the e-mail [email protected] is considered twice in the answer. Note that in this example the e-mail entries overlap inside the string.
在第一个测试用例中,所有合法电子邮件地址的子串均起始于单词 “agapov” 中的某个字母,并结束于单词 “com” 中的某个字母。
在第二个测试用例中,请注意电子邮件地址 [email protected] 在答案中被计算了两次。注意,在本例中,电子邮件地址在字符串内部存在重叠。
输入解题思路,AI测评打分。不知道怎么写?