Codeforces Round #294 (Div. 2)
来源:互联网 发布:比特币高频交易编程 编辑:程序博客网 时间:2024/05/16 12:59
519A
519D
A and B and Chess
/*********************************************** * Author: fisty * Created Time: 2015/2/28 21:12:09 * File Name : A.cpp *********************************************** */#include <iostream>#include <cstring>#include <deque>#include <cmath>#include <queue>#include <stack>#include <list>#include <map>#include <set>#include <string>#include <vector>#include <cstdio>#include <bitset>#include <algorithm>using namespace std;#define Debug(x) cout << #x << " " << x <<endl#define Memset(x, a) memset(x, a, sizeof(x))const int INF = 0x3f3f3f3f;typedef long long LL;typedef pair<int, int> P;#define FOR(i, a, b) for(int i = a;i < b; i++)int _white(char c){ int n; switch(c){ case 'Q': n = 9;break; case 'R': n = 5;break; case 'B': n = 3;break; case 'N': n = 3;break; case 'P': n = 1;break; dafault: n = 0;break; } return n;}int _black(char c){ int n; switch(c){ case 'q': n = 9;break; case 'r': n = 5;break; case 'b': n = 3;break; case 'n': n = 3;break; case 'p': n = 1;break; dafault: n = 0;break; } return n;}int main() { //freopen("in.cpp", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); string s; int white = 0;int black = 0; FOR(i, 0, 8){ cin >> s; for(int j = 0;j < s.length(); j++){ if(s[j] <= 'Z' && s[j] >= 'A'){ white += _white(s[j]); }else if(s[j] <= 'z' && s[j] >= 'a'){ black += _black(s[j]); } } } //Debug(white); //Debug(black); if(white > black){ cout << "White" << endl; }else if(white < black){ cout << "Black" << endl; }else{ cout << "Draw" << endl; } return 0;}519B
A and B and Compilation Errors
A和B 比较,B和C比较。全部排序,遇到第一个不同数字输出并跳出比较/*********************************************** * Author: fisty * Created Time: 2015/2/28 21:43:51 * File Name : 294B.cpp *********************************************** */#include <iostream>#include <cstring>#include <deque>#include <cmath>#include <queue>#include <stack>#include <list>#include <map>#include <set>#include <string>#include <vector>#include <cstdio>#include <bitset>#include <algorithm>using namespace std;#define Debug(x) cout << #x << " " << x <<endl#define Memset(x, a) memset(x, a, sizeof(x))const int INF = 0x3f3f3f3f;typedef long long LL;typedef pair<int, int> P;#define FOR(i, a, b) for(int i = a;i < b; i++)#define MAX_N 100100 int a[MAX_N], b[MAX_N], c[MAX_N];int main() { //freopen("in.cpp", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; Memset(a, 0); Memset(b, 0); Memset(c, 0); FOR(i, 0, n){ cin >> a[i]; } FOR(i, 0, n-1){ cin >> b[i]; } FOR(i, 0, n-2){ cin >> c[i]; } sort(a, a + n); sort(b, b + n-1); sort(c, c + n-2); for(int i = 0;i < n; i++){ if(a[i] != b[i]){ cout << a[i] << endl; break; } } for(int i = 0;i < n-1; i++){ if(b[i] != c[i]){ cout << b[i] << endl; break; } } return 0;}
A and B and Team Training
如果n > m 那么采取 n 取两个m 取一个的方案,/*********************************************** * Author: fisty * Created Time: 2015/2/28 21:54:12 * File Name : 294C.cpp *********************************************** */#include <iostream>#include <cstring>#include <deque>#include <cmath>#include <queue>#include <stack>#include <list>#include <map>#include <set>#include <string>#include <vector>#include <cstdio>#include <bitset>#include <algorithm>using namespace std;#define Debug(x) cout << #x << " " << x <<endl#define Memset(x, a) memset(x, a, sizeof(x))const int INF = 0x3f3f3f3f;typedef long long LL;typedef pair<int, int> P;#define FOR(i, a, b) for(int i = a;i < b; i++)#define MAX_N 8000int main() { //freopen("in.cpp", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; int ans = 0; while(n >= 1 && m >= 1 && m + n >= 3){ ans++; if(n > m){ n -= 2; m--; }else{ m -= 2; n--; } } cout << ans << endl; return 0;}
519D
A and B and Interesting Substrings
首先维护前缀和,mp[i][v]表示以字符i结束的前缀和为V出现了几次
根据题目要求,如果字符u 和 v 中间值为零 那么两者的前缀和相等.
/*********************************************** * Author: fisty * Created Time: 2015/2/28 22:46:13 * File Name : 294D.cpp *********************************************** */#include <iostream>#include <cstring>#include <deque>#include <cmath>#include <queue>#include <stack>#include <list>#include <map>#include <set>#include <string>#include <vector>#include <cstdio>#include <bitset>#include <algorithm>using namespace std;#define Debug(x) cout << #x << " " << x <<endl#define Memset(x, a) memset(x, a, sizeof(x))const int INF = 0x3f3f3f3f;typedef long long LL;typedef pair<int, int> P;#define FOR(i, a, b) for(int i = a;i < b; i++)#define MAX_N 100000string s;int a[30];map<LL, int> mp[MAX_N];int main() { //freopen("in.cpp", "r", stdin); cin.tie(0); ios::sync_with_stdio(false); for(int i = 0;i < 26; i++){ cin >> a[i]; } cin >> s; int n = s.length(); LL ans = 0; LL v = 0; for(int i = 0;i < n; i++){ ans += mp[s[i]-'a'][v]; v += a[s[i]-'a']; mp[s[i]-'a'][v]++; } cout << ans << endl; return 0;}
0 0
- Codeforces Round #294 (Div. 2)
- Codeforces Round #294 (Div. 2)
- Codeforces Round #294 (Div. 2)
- Codeforces Round #294 (Div. 2)
- Codeforces Round #294 (Div. 2)
- Codeforces Round #294 (Div. 2)
- Codeforces Round #294 (Div. 2)
- Codeforces Round #294 (Div. 2)
- Codeforces Round #294 (Div. 2) ABCDE
- Codeforces Round #294 (Div. 2) C
- Codeforces Round #294 (Div. 2) D
- Codeforces Round #294 (Div. 2) (ABCDE题解)
- Codeforces Round #294 (Div. 2) E
- Codeforces Round #102 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #103 (Div. 2)
- Codeforces Round #104 (Div. 2)
- Codeforces Round #105 (Div. 2)
- ie主页修改
- Android基站定位——通过手机信号获取基站信息
- activity启动模式笔记
- wav转amr以及简单调整音量
- bzoj 3877: [Ahoi2014]保龄球
- Codeforces Round #294 (Div. 2)
- 消息字节——MessageBytes
- JS高程NO3--基本概念(语法,数据类型,操作符,语句,函数)
- iOS第一个项目错误个人整理
- 2015.03.01 mysql SQL语句获取两个经纬度之间的距离
- 问题标记一下
- 循环-11. 水仙花数(20)
- HASH表的实现
- AFNetworking初探