1. 程式人生 > >【Weird Game】【CodeForces - 299C】(思維)

【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 tron 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 0,每次雙方都優先用1進行對決,且每次這個位兩個人只能選擇一個,那麼就是貪心,每次都用自己的0 去堵死對方的1,以使自己的1 能更可能的留到最後。

ac程式碼:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

const int maxn=1e7+100;

char a[maxn],b[maxn];

int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		n*=2;
		cin>>a>>b;
		int ans1=0,ans2=0,ans3=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]=='1'&&b[i]=='1')
				ans1++;
			if(a[i]=='1'&&b[i]=='0')
				ans2++;
			if(a[i]=='0'&&b[i]=='1')
				ans3++;
		}
		ans1%=2;
		if(ans1+ans2==ans3-1)
			ans3--;
		if(ans1+ans2==ans3)	
			printf("Draw\n");
		else if(ans1+ans2>ans3)
			printf("First\n");
		else
			printf("Second\n");
		
			
	}
}