CodeForces Round #294 Div.2
2015-03-01 20:13
309 查看
这个题目感觉略简单,但是后两题还是一个没做出来╮(╯_╰)╭
A. A and B and Chess
就是比较一下棋盘上两边的权重。
代码君
A. A and B and Chess
就是比较一下棋盘上两边的权重。
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn = 100000 + 10; int w[30]; char s[maxn]; LL sum[maxn]; map<LL, int> cnt[30]; int main() { //freopen("in.txt", "r", stdin); for(int i = 0; i < 26; i++) scanf("%d", &w[i]); scanf("%s", s + 1); int l = strlen(s + 1); LL ans = 0; for(int i = 1; i <= l; i++) { int x = s[i] - 'a'; sum[i] = sum[i - 1] + w[x]; ans += cnt[x][sum[i-1]]; cnt[x][sum[i]]++; } printf("%I64d\n", ans); return 0; }
代码君
相关文章推荐
- codeforces Round#158 Div.2 C
- Codeforces #Round 406(Div.2)
- Codeforces Round 389 Div.2 B. Santa Claus and Keyboard Check(模拟)
- codeforces Round 314 div.2 分类: codeforces introspect 2015-08-08 13:52 7人阅读 评论(0) 收藏
- Codeforces Round 261 Div.2 D Pashmak and Parmida&#39;s problem --树状数组
- codeforces round #236 div.2 B
- Codeforces Round #395 (Div.2) C-Timofey and a tree 树型dp
- Codeforces #Round 785(Div.2)
- Codeforces Round 389 Div.2 B. Santa Claus and Keyboard Check(模拟)
- codeforces Round 314 div.2
- Codeforces Round 261 Div.2 E Pashmak and Graph --DAG上的DP
- Codeforces Round #283 Div.2 D Tennis Game --二分
- codeforces Intel Code Challenge Final Round (div.1 + div.2 combined)
- Codeforces Round #424 Div.2 A B C D E F
- Codeforces Round 389 Div.2 B. Santa Claus and Keyboard Check(模拟)
- Codeforces Round 465 div.2 C&D
- Codeforces Aim Tech Round 3 (Div.2 )B.Checkpoints【思维】
- CodeForces Round #290 Div.2
- Codeforces Round #294 (Div. 2) -- A. A and B and Chess
- codeforces Round #184 Div.2 - B Continued Fractions