Codeforces Round #300 D. Weird Chess 水题
D. Weird Chess
Time Limit: 1 Sec Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/538/problem/D
Description
Igor has been into chess for a long time and now he is sick of the game by the ordinary rules. He is going to think of new rules of the game and become world famous.
Igor's chessboard is a square of size n × n cells. Igor decided that simple rules guarantee success, that's why his game will have only one type of pieces. Besides, all pieces in his game are of the same color. The possible moves of a piece are described by a set of shift vectors. The next passage contains a formal description of available moves.
Let the rows of the board be numbered from top to bottom and the columns be numbered from left to right from 1 to n. Let's assign to each square a pair of integers (x, y) — the number of the corresponding column and row. Each of the possible moves of the piece is defined by a pair of integers (dx, dy); using this move, the piece moves from the field (x, y) to the field (x + dx, y + dy). You can perform the move if the cell (x + dx, y + dy) is within the boundaries of the board and doesn't contain another piece. Pieces that stand on the cells other than (x, y) and (x + dx, y + dy) are not important when considering the possibility of making the given move (for example, like when a knight moves in usual chess).
Igor offers you to find out what moves his chess piece can make. He placed several pieces on the board and for each unoccupied square he told you whether it is attacked by any present piece (i.e. whether some of the pieces on the field can move to that cell). Restore a possible set of shift vectors of the piece, or else determine that Igor has made a mistake and such situation is impossible for any set of shift vectors.
Input
The first line contains a single integer n (1 ≤ n ≤ 50).
The next n lines contain n characters each describing the position offered by Igor. The j-th character of the i-th string can have the following values:
- o — in this case the field (i, j) is occupied by a piece and the field may or may not be attacked by some other piece;
- x — in this case field (i, j) is attacked by some piece;
- . — in this case field (i, j) isn't attacked by any piece.
It is guaranteed that there is at least one piece on the board.
Output
If there is a valid set of moves, in the first line print a single word 'YES' (without the quotes). Next, print the description of the set of moves of a piece in the form of a (2n - 1) × (2n - 1) board, the center of the board has a piece and symbols 'x' mark cells that are attacked by it, in a format similar to the input. See examples of the output for a full understanding of the format. If there are several possible answers, print any of them.
If a valid set of moves does not exist, print a single word 'NO'.
Sample Input
5
oxxxx
x...x
x...x
x...x
xxxxo
Sample Output
....x....
....x....
....x....
....x....
xxxxoxxxx
....x....
....x....
....x....
....x....
HINT
题意
给你一个棋盘,o代表旗子的位置,x代表能够攻击的地方,让你输出这个旗子的攻击范围
题解:
啊,这道题拿攻击范围去推前面的给你的棋盘,去检查是否每一个o都满足,用答案去推棋盘
有这个逆向思维做这道题就好多了= =
代码:
//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 55
#define mod 10007
#define eps 1e-9
int Num;
char CH[];
//const int inf=0x7fffffff; //нчоч╢С
const int inf=0x3f3f3f3f;
/* inline void P(int x)
{
Num=0;if(!x){putchar('0');puts("");return;}
while(x>0)CH[++Num]=x%10,x/=10;
while(Num)putchar(CH[Num--]+48);
puts("");
}
*/
inline ll read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
inline void P(int x)
{
Num=;if(!x){putchar('');puts("");return;}
while(x>)CH[++Num]=x%,x/=;
while(Num)putchar(CH[Num--]+);
puts("");
}
//************************************************************************************** char s[][]; int vis[][];
int dp[][];
int main()
{
int n=read();
for(int i=;i<=n;i++)
scanf("%s",s[i]+);
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
if(s[i][j]=='o')
{
for(int i1=;i1<=n;i1++)
{
for(int j1=;j1<=n;j1++)
{
if(s[i1][j1]=='.')
vis[n+i1-i][n+j1-j]=;
}
}
}
}
} for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
if(s[i][j]=='o')
{
for(int i1=;i1<=n;i1++)
{
for(int j1=;j1<=n;j1++)
{
if(s[i1][j1]=='x'&&!vis[n+i1-i][n+j1-j])
dp[i1][j1]=;
}
}
}
}
} for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
if(s[i][j]=='x'&&dp[i][j]!=)
{
puts("NO");
return ;
}
}
}
puts("YES");
for(int i=;i<=*n-;i++)
{
for(int j=;j<=*n-;j++)
{
if(i==n&&j==n)
cout<<"o";
else if(vis[i][j])
cout<<".";
else
cout<<"x";
}
cout<<endl;
}
}
Codeforces Round #300 D. Weird Chess 水题的更多相关文章
- Codeforces Round #300 A. Cutting Banner 水题
A. Cutting Banner Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/pro ...
- Codeforces Round #300 B. Quasi Binary 水题
B. Quasi Binary Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/538/probl ...
- Educational Codeforces Round 7 B. The Time 水题
B. The Time 题目连接: http://www.codeforces.com/contest/622/problem/B Description You are given the curr ...
- Educational Codeforces Round 7 A. Infinite Sequence 水题
A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/622/problem/A Description Consider the ...
- Codeforces Round #336 (Div. 2)-608A.水题 608B.前缀和
A题和B题... A. Saitama Destroys Hotel time limit per test 1 second memory limit per test 256 megabyte ...
- Educational Codeforces Round 11 A. Co-prime Array 水题
A. Co-prime Array 题目连接: http://www.codeforces.com/contest/660/problem/A Description You are given an ...
- Educational Codeforces Round 10 C. Foe Pairs 水题
C. Foe Pairs 题目连接: http://www.codeforces.com/contest/652/problem/C Description You are given a permu ...
- A. Yellow Cards ( Codeforces Round #585 (Div. 2) 思维水题
---恢复内容开始--- output standard output The final match of the Berland Football Cup has been held recent ...
- Codeforces Round #345(Div. 2)-651A.水题 651B.。。。 651C.去重操作 真是让人头大
A. Joysticks time limit per test 1 second memory limit per test 256 megabytes input standard input o ...
随机推荐
- fileIO和OS操作文件和目录
1.FileIO操作文件 # 文件IO,读取文件和创建文件 # 1.读取键盘输入 x=input("please input number") print("您输入的是& ...
- Ubuntu 10.04 分辨率调整
最近学长们看了我的本本都在问我,显卡驱动是不是出现什么问题了···分辨率这么差.当时我的分辨率是1024X768,于是我就想修改我的屏幕分辨率改成1280X800.本来很简单的事情,我做起来却非常的曲 ...
- C++ 和Java继承机制的比较
摘要: C++支持类的多继承,而Java采用类的单继承.C++中的继承成分只有类(模板属于带参数的类,结构和联合是特殊的类),Java中除了类还有接口的继承,而且允许接口的多继承,可以间接地实现类多继 ...
- Maven核心概念
一.坐标 在平面几何中,坐标(x,y)可以标识平面中唯一的一个点.在maven中,坐标是为了定位一个唯一确定的jar包.Maven世界拥有大量构建,我们需要找一个用来唯一标识一个构建的统一规范:拥有了 ...
- Linux 进程间通信(一)(经典IPC:管道、FIFO)
管道 管道是Unix系统IPC的最古老方式,有两种局限性: (1) 历史上它们是半双工的(即数据只能在一个方向上流动),虽然现在某些系统提供了全双工管道,但是为了可移植性,不要抱有绝对的全双工假设 ...
- 【hdoj_1133】Buy the Ticket(卡特兰数+大数)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1133 题目的意思是,m个人只有50元钱,n个人只有100元整钱,票价50元/人.现在售票厅没钱,只有50元 ...
- JavaWeb知识回顾-servlet简介。
现在公司主要用jsp+servlet这种原生的开发方式,用的是uap的开发平台,所以趁着这个时候把有关javaweb的知识回顾一下. 首先是从servlet开始. 一.什么是Servlet?(是一些理 ...
- python进行des加密解密,而且可以与JAVA进行互相加密解密
import binasciifrom pyDes import des, CBC, PAD_PKCS5import uuidimport time # pip install -i https:// ...
- Delphi idHttpServer接收Http Get请求解码问题
引用 Httpapp单元,使用Httpdecode函数进行解码 procedure TFrmMain.HTTPServerCommandGet(AThread: TIdPeerThread; AReq ...
- Adsafe 导致win10 中窗口错位
域账号使用,出现上述情况,干掉后一切恢复正常... 还好家里的本地管理员账号使用一切正常,不然又被广告占领了