标签:acm
const int MAXN = 1100000; char ipt[MAXN]; LL alp[MAXN], number[MAXN], under[MAXN], succ[MAXN]; //从头开始字母的个数;从头开始的数字个数;从头开始的下划线个数;当前符号之后有几个连续的字母 int main() { // freopen("in.txt", "r", stdin); while (~RS(ipt + 1)) { vector<int> vt; CLR(under, 0); CLR(alp, 0); CLR(number, 0); CLR(succ, 0); ipt[0] = ‘.‘; int len = strlen(ipt); ipt[len++] = ‘@‘; ipt[len] = 0; REP(i, len) { if (i) { alp[i] = alp[i - 1]; number[i] = number[i - 1]; under[i] = under[i - 1]; } if (isalpha(ipt[i])) alp[i]++; else if (isdigit(ipt[i])) number[i]++; else if (ipt[i] == ‘_‘) under[i]++; else { vt.push_back(i); } } int tt = 0; LL ans = 0; FED(i, len - 1, 0) { succ[i] = tt; if (isalpha(ipt[i])) tt++; else tt = 0; } FF(i, 1, vt.size() - 1) { int cur = vt[i], nxt = vt[i + 1]; if (ipt[cur] == ‘@‘ && ipt[nxt] == ‘.‘ && under[nxt] == under[cur] && nxt - cur > 1) { ans += succ[nxt] * (alp[cur] - alp[vt[i - 1]]); } } cout << ans << endl; } return 0; }
Coder-Strike 2014 - Round 1__E-mail Addresses
标签:acm
原文地址:http://blog.csdn.net/wty__/article/details/24587231