Croc Champ 2013 - Round 2 (Div. 2 Edition)-C Weird Gam

这题实在耗我很长时间。主要浪费在区间边界的特判。自然界的对称性很好,我们往往可以考虑特殊情况,处理了一半,另一半相似的推出。这题,比较容易猜出一个优先级。即{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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值