Croc Champ 2013 - Round 2 (Div. 2 Edition)-C Weird Gam
来源:互联网 发布:free mobile java亚洲 编辑:程序博客网 时间:2024/05/16 11:44
这题实在耗我很长时间。主要浪费在区间边界的特判。自然界的对称性很好,我们往往可以考虑特殊情况,处理了一半,另一半相似的推出。这题,比较容易猜出一个优先级。即{1,1},{0,1},{1,0}{0,0} 不影响答案根据{1,1}出现的次数的奇偶性等价成0,1然后统计{0,1}{1,0}出现次数特判一下吧。。纸上画一下。。这题有一个特点就是很多东西都互相抵消了,这就出现了一个常见的情况,余2为偶结果+1。意会吧。
今天重写,发现以前代码相当挫比。。。
/* * Author: raylee * Created Time: 2014/1/21 15:13:17 * File Name: a.cpp *///#pragma comment(linker, "/STACK:102400000,102400000")#include<cstdio>#include<iostream>#include<cstring>#include<cstdlib>#include<cmath>#include<algorithm>#include<string>#include<map>#include<set>#include<vector>#include<queue>#include<stack>#include<ctime>#include<climits>using namespace std;#define pb push_back#define vi vector<int>#define clr( x , y ) memset(x, y, sizeof(x))typedef long long ll;char str1[ 2 * 1001000 ], str2[ 2 * 1001000 ];int main(){ ios::sync_with_stdio(false); int n; cin>>n; cin>>str1 + 1; cin>>str2 + 1; int s11 = 0, s10 = 0, s01 = 0; for(int i = 1; i <= 2 * n; i++){ if(str1[ i ] == '1' && str2[ i ] == '1') s11++; else if(str1[ i ] == '0' && str2[ i ] == '1') s01++; else if(str1[ i ] == '1' && str2[ i ] == '0') s10++; } int score_fir = 0, score_sec = 0; score_fir = s11 - s11 / 2; score_sec = s11 / 2; if(s11 % 2 == 1){ if(s01){ s01--; score_sec++; }else if(s10){ s10--; } else { cout<<"First"<<endl; return 0; } } if(s10 > s01){ score_fir += s01; score_sec += s01; s10 -= s01; int res = s10; score_fir += res - res/2; }else if(s10 < s01){ score_fir += s10; score_sec += s10; s01 -= s10; int res = s01; score_sec += res/2; } if(score_fir > score_sec) cout<<"First"<<endl; else if(score_fir < score_sec) cout<<"Second"<<endl; else cout<<"Draw"<<endl; return 0;}
- Croc Champ 2013 - Round 2 (Div. 2 Edition)-C Weird Gam
- Croc Champ 2013 - Round 2 (Div. 2 Edition) A题
- Croc Champ 2013 - Round 2 (Div. 2 Edition)--C 字符串处理
- Croc Champ 2013 - Round 2 (Div. 2 Edition)——A,B,C
- Codeforces Croc Champ 2012 - Round 2 (Unofficial Div. 2 Edition)
- Croc Champ 2013 - Round 2 Div. 2 D
- Croc Champ 2013 - Round 2 题解
- Croc Champ 2013 - Round 2 题解
- CF_Croc Champ 2012 - Round 2 (Unofficial Div. 2 Edition)
- Codeforces Croc Champ 2012 - Round 2 B. Word Cut
- Croc Champ 2013 - Qualification Round(完全)
- Croc Champ 2013 - Round 1(完全)
- Croc Champ 2013 - Qualification Round题解
- Croc Champ 2013 - Round 1 题解
- cf Croc Champ 2012 - Round 1 C. Spiral Maximum
- CF Croc Champ 2013 - Finals (online version, Div. 1) C(greedy)
- Croc Champ 2013 - Round 1——E
- Croc Champ 2013 - Qualification Round A题解题报告
- 有关错误:buffer i/o error on device fd0,logical block 0
- MFC删除类的小窍门
- PHP开发框架的现状和展望
- Laravel+Angularjs+D3打造可视化数据,RESTful+Ajax
- Java异常使用一个不错的整理
- Croc Champ 2013 - Round 2 (Div. 2 Edition)-C Weird Gam
- Start
- 权限设计及算法(PHPE)
- 易飞登录密码
- 一步一步学android控件(之八) —— ImageView
- 基于JSON的高级AJAX开发技术
- ORACLE单行函数与多行函数之六:通用函数示例
- Ajax:拥抱JSON,让XML走开
- dilworth定理{偏序集}{百度百科}