日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Weird Game CodeForces - 299C

發布時間:2023/12/15 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Weird Game CodeForces - 299C 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。