F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Game of Arrays

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 642    Accepted Submission(s): 171


Problem Description
Tweek and Craig are good friends and always playing together. And they just invented a new game when doing their math homework.

First of all, they write three arrays $A$, $B$, and $C$, each with $N$ numbers. Then on the black board, they write those arrays as

$$A + B = C$$

If the equation is satisfied, it means for each position $i$ from $1$ to $N$, there are $A_i + B_i = C_i$ holds.

Of course, this equation is not always satisfied at the very beginning.

Fortunately, for arrays $A$, $B$ and $C$, some numbers are $changeable$, while other's are not. Those $changeable$ numbers' positions are determined before the game begins.

During the game, Tweek and Craig will take turns, trying to change a number from an array. Tweek plays first.

In each turn, the player can choose a $changeable$ number from an array, and substract it by one. However, no negative numbers should appear, so the chosen number cannot be $0$ before substraction.

Tweek's goal is to make the equation satisfied during the game, while Craig's goal is to prevent it to happen.

The game ends when the equation is satisfied (a win for Tweek) or there are no possible moves but still $A + B \neq C$ (means there is at least one $i \in \left[1, N\right]$, where $A_i + B_i \neq C_i$, which is a win for Craig).

Given $A$, $B$ and $C$, and the position of $changeable$ numbers for each array, your task is to determine the winner.
 

Input
First line contains an integer $T$, which indicates the number of test cases.

Every test case begins with an integers $N$, which is the length of array $A$, $B$ and $C$.

The $2^{nd}$ line and $3^{rd}$ line describe the array $A$. The $2^{nd}$ line contains $N$ intergers $A_1$, $A_2$, $\cdots$, $A_N$, indicating the elements in array $A$. The $3^{rd}$ line contains $N$ intergers $u_1$, $u_2$, $\cdots$, $u_N$, and $u_i$ is $1$ if $A_i$ is $changeable$, otherwise $u_i$ is $0$.

The $4^{th}$ line and $5^{th}$ line describe the array $B$. The $4^{th}$ line contains $N$ intergers $B_1$, $B_2$, $\cdots$, $B_N$, indicating the elements in array $B$. The $5^{th}$ line contains $N$ intergers $v_1$, $v_2$, $\cdots$, $v_N$, and $v_i$ is $1$ if $B_i$ is $changeable$,otherwise $v_i$ is $0$.

The $6^{th}$ line and $7^{th}$ line describe the array $C$. The $6^{th}$ line contains $N$ intergers $C_1$, $C_2$, $\cdots$, $C_N$, indicating the elements in array $C$. The $7^{th}$ line contains $N$ intergers $w_1$, $w_2$, $\cdots$, $w_N$, and $w_i$ is $1$ if $C_i$ is $changeable$,otherwise $w_i$ is $0$.

$\cdot$ $1 \leq T \leq 2000$.

$\cdot$ for 75% data, $1 \leq N \leq 10$.

$\cdot$ for 95% data, $1 \leq N \leq 50$.

$\cdot$ for 100% data, $1 \leq N \leq 100$.

$\cdot$ $0 \leq A_i, B_i, C_i \leq 10^9$.

$\cdot$ both $u_i, v_i, w_i$ is either $0$ or $1$.
 

Output
For every test case, you should output "Case #x: y", where $x$ indicates the case number and counts from $1$, and $y$ is the winner of the game.
 

Sample Input
3 2 4 3 1 1 4 4 0 1 5 5 0 0 2 4 4 1 1 4 4 0 0 5 5 0 0 2 4 4 1 1 4 4 0 0 4 4 0 0
 

Sample Output
Case #1: Tweek Case #2: Craig Case #3: Tweek
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-18 20:43:25, Gzip enabled