Yaroslav, Andrey and Roman can play cubes for hours and hours. But the game is for three, so when Roman doesn’t show up, Yaroslav and Andrey play another game.

Roman leaves a word for each of them. Each word consists of 2·n binary characters “0” or “1”. After that the players start moving in turns. Yaroslav moves first. During a move, a player must choose an integer from 1 to 2·n, which hasn’t been chosen by anybody up to that moment. Then the player takes a piece of paper and writes out the corresponding character from his string.

Let’s represent Yaroslav’s word as s = s1s2… s2n. Similarly, let’s represent Andrey’s word as t = t1t2… t2n. Then, if Yaroslav choose number k during his move, then he is going to write out character sk on the piece of paper. Similarly, if Andrey choose number r during his move, then he is going to write out character tr on the piece of paper.

The game finishes when no player can make a move. After the game is over, Yaroslav makes some integer from the characters written on his piece of paper (Yaroslav can arrange these characters as he wants). Andrey does the same. The resulting numbers can contain leading zeroes. The person with the largest number wins. If the numbers are equal, the game ends with a draw.

You are given two strings s and t. Determine the outcome of the game provided that Yaroslav and Andrey play optimally well.

Input
The first line contains integer n (1 ≤ n ≤ 106). The second line contains string s — Yaroslav’s word. The third line contains string t — Andrey’s word.

It is guaranteed that both words consist of 2·n characters “0” and “1”.

Output
Print “First”, if both players play optimally well and Yaroslav wins. If Andrey wins, print “Second” and if the game ends with a draw, print “Draw”. Print the words without the quotes.

Examples
Input
2
0111
0001
Output
First
Input
3
110110
001001
Output
First
Input
3
111000
000111
Output
Draw
Input
4
01010110
00101101
Output
First
Input
4
01100000
10010011
Output
Second

两个人玩游戏,第一个人选过的地方,第二个人就不能选了。看看最后是谁选的一多。
分析一下:如果两个字符串相同的地方都是1,那么就看奇偶性就好了。

代码如下:

#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
long n,i,f,g,h;
string s,t;
int main() {cin >> n >> s >> t;for (i=0;i<2*n;i++) {if (s[i]=='1') f++;if (t[i]=='1') g++;if (s[i]+t[i]==98) h++;}if (h%2==1) g--;if (f>g) cout << "First" << endl;else if (g-f>1) cout << "Second" << endl;else cout << "Draw" << endl;return 0;
}

努力加油a啊,(o)/~

Weird Game CodeForces - 299C相关推荐

  1. 【CodeForces - 299C 】Weird Game (思维,模拟,贪心,博弈,OAE思想)

    题干: Yaroslav, Andrey and Roman can play cubes for hours and hours. But the game is for three, so whe ...

  2. Educational Codeforces Round 39 B Weird Subtraction Process

    传送门 模拟,写的比较土,别吐槽 #include <bits/stdc++.h> using namespace std; typedef long long ll ; typedef ...

  3. 【CodeForces - 789D】Weird journey(思维,图的性质,tricks,有坑)

    题干: Little boy Igor wants to become a traveller. At first, he decided to visit all the cities of his ...

  4. Codeforces Round 775(Div.2) Problem C Weird Sum(匿名函数的使用)

    原题链接 C++ Lambda函数(匿名函数)的使用方法 ​ 首先了解一下 C++ 匿名函数的基本使用方法 基本语法 //[捕获列表](参数列表)->返回类型{函数体} auto f = []( ...

  5. Codeforces Round #181 (Div. 2) C. Beautiful Numbers 排列组合 暴力

    C. Beautiful Numbers 题目连接: http://www.codeforces.com/contest/300/problem/C Description Vitaly is a v ...

  6. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题

    A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...

  7. codeforces #261 C题 Pashmak and Buses(瞎搞)

    题目地址:http://codeforces.com/contest/459/problem/C C. Pashmak and Buses time limit per test 1 second m ...

  8. Codeforces Round #775 (Div. 2, based on Moscow Open Olympiad in Informatics)简训

    Codeforces Round #775 (Div. 2, based on Moscow Open Olympiad in Informatics)简训 导语 涉及的知识点 题目 A Game B ...

  9. CodeForces 375D Tree and Queries

    传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...

最新文章

  1. 对Tensor结果使用opencv2中的操作
  2. 一本通 1282:最大子矩阵
  3. linux中fcntl()、lockf、flock的区别
  4. python入坑指南_Rust入坑指南:万物初始
  5. storagesky存储天地
  6. python元组和列表的联系_Python | 一文看懂Python列表、元组和字符串操作
  7. 雷军变身IPO收割机:坐拥4家上市公司,今年至少收获8个IPO!
  8. Maven的下载与安装
  9. idea迁移到其他电脑,省去重新安装破解及配置
  10. jquery修改样式通过类
  11. 计算机系统操作工中级工试卷,计算机系统操作工中级理论试题及答案.doc
  12. 所谓高手,就是把自己活成了贝叶斯定理
  13. idea 开源申请授权到期怎么办
  14. Altium Designer,打开PCB文件,提示:File type not recognised
  15. matlab 自写iradon,matlab的radon变换
  16. 安卓脚本判断运作的是不是root,su
  17. 使用CSS控制表格设计出课程表实验内容:编写一个网页,内容为本学期本班的课程表,并使用CSS设计课程表的显示样式
  18. Kafka生产者和消费者
  19. 仿牛客项目(持续更新)
  20. KubeCon China 2021 阿里云专场来了!这些首日亮点不容错过

热门文章

  1. IOS15之优雅的使用UITableView
  2. IOS网络框架的Alamofire5.4高版本网络工具封装
  3. IOS之截取特定字符串
  4. IOS基础之NSFounation框架的NSDictionary,NSMutableDictionary的使用
  5. solaris php,solaris 十系统上架构phpwind论坛环境(转)
  6. 华为手机线刷工具_华为手机天气小工具误删/移除/丢失/不见了怎么办?
  7. apache camel 相关配置_Apache Camel的Java编程入门指南
  8. python windows程序管理器_获取使用python运行的windows应用程序的列表
  9. Android开发之线程池管理ThreadPoolExecutor和Executors.newSingleThreadExecutor()
  10. Unable to create '.git/index.lock': File exists