| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1111 人关注过本帖
标题:帮忙看看这道题目的思路,我觉得奇怪
只看楼主 加入收藏
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
结帖率:73.91%
收藏
 问题点数:0 回复次数:7 
帮忙看看这道题目的思路,我觉得奇怪
Game

Time Limit:1000MS  Memory Limit:65536K
Total Submit:6 Accepted:2

Description

Bill is fond of computer games. He likes to analyze games and to provide efficient solutions. Now, he is studying the following game. The game starts with a n x n matrix filled with positive integers. When it is her/his turn, a player can delete the last row or the last column of the matrix, if the sum of the numbers in that row/column is even. If a player cannot delete the last row or the last column on his turn, then he loses the game. Bill thinks that this game can be classified as first player wins (W) or first player loses (L). First player wins means that the first player has a strategy to win, no matter how the second player plays the game. First player loses means that no matter what the first player does the second player has a strategy to win.
Bill is also a skilled programmer. He wants to write a program to classify the game quickly. Can you help him?

Input

The program input is from a text file. Each data set in the file stands for a particular game. A data set starts with the number n (n  1000), the matrix dimension, followed by the positive integers in the matrix. The program has to print W if the first player wins the game, or L if the first player loses the game.

Output

White spaces can occur freely in the input. The input data are correct and terminate with an end of file. For each set of data the program prints the result to the standard output from the beginning of the line. An input/output sample is in the table bellow. There are two data sets. In the first case, the matrix dimension n is 2. The integers in the matrix are: 2 4 6 8. The result for the data set is L, meaning that no matter what the first player does, the second player wins.

Sample Input


2
2 4
6 8
3
5 4 2
1 5 9
7 3 8
Sample Output


L
W

帮忙看看这道题目的思路
搜索更多相关主题的帖子: efficient following positive computer studying 
2011-08-22 14:16
xinbitianga
Rank: 1
等 级:新手上路
帖 子:3
专家分:6
注 册:2011-8-22
收藏
得分:0 
路过,英文不懂
2011-08-22 14:23
voidx
Rank: 12Rank: 12Rank: 12
来 自:邯郸
等 级:火箭侠
帖 子:1250
专家分:3538
注 册:2011-4-7
收藏
得分:0 
哪里奇怪?
2011-08-22 14:40
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
收藏
得分:0 
回复 3楼 voidx
可不可以说一下这个思路可不可以说一下这个思路
2011-08-22 14:48
者好爱程编
Rank: 2
等 级:论坛游民
帖 子:68
专家分:46
注 册:2011-8-22
收藏
得分:0 
菜鸟路过 ……
2011-08-22 14:52
laoyang103
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
来 自:内蒙古包头
等 级:贵宾
威 望:19
帖 子:3082
专家分:11056
注 册:2010-5-22
收藏
得分:0 
看在我四级刚刚挂掉的份上  给我中文吧

                                         
===========深入<----------------->浅出============
2011-08-22 15:26
voidx
Rank: 12Rank: 12Rank: 12
来 自:邯郸
等 级:火箭侠
帖 子:1250
专家分:3538
注 册:2011-4-7
收藏
得分:0 
这个,貌似只能暴力了,好在规模很小。
写个模拟过程,让两个玩家逐个取就好了,知道出现必败配置,也就是最后一行和最后一列的和都为奇数。
小技巧:读取数据的时候这样做
    scanf("%d", &matrix[i][j]);
    matrix[i][j] &= 1;
2011-08-22 17:02
怎么会这样子
Rank: 2
来 自:广州
等 级:论坛游民
帖 子:31
专家分:39
注 册:2011-8-20
收藏
得分:0 
哦,不懂个英文的路过!
2011-08-22 23:08
快速回复:帮忙看看这道题目的思路,我觉得奇怪
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021209 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved