南邮 OJ 1390 Rooks
来源:互联网 发布:windows启动菜单修改 编辑:程序博客网 时间:2024/05/29 16:51
Rooks
总提交 : 62 测试通过 : 43
比赛描述
Jake and Sully are playing around with a chessboard one night after working with their avatars all
day. They decide it would be interesting to place some rooks on the chessboard in a way that no rook
can threaten another rook. Since rooks move along rows and columns, this means two rooks may not
be on the same row or column. Your goal is to write a program to determine whether any rooks are
threatened.
输入
Chessboards are 8x8 boards with positions between (1,1) and (8,8). The input begins with the
number of chess boards. Each chessboard is on a separate line and begins with the number of rooks,
followed by the column and row positions of each rook.
输出
For each chessboard, your program should output the words ”SAFE” or ”NOT SAFE” on a
single line.
样例输入
2
3 1 1 2 6 8 8
2 2 3 1 3
样例输出
SAFE
NOT SAFE
提示
undefined
题目来源
Internet
#include<iostream>int main(){int cas,n,i,j,row,colum;bool safe;scanf("%d",&cas);while(cas--){safe = 1;row = colum = 0;scanf("%d",&n);while(n--){scanf("%d%d",&i,&j);if(safe){if(row & (1<<i)){safe = 0;}else{row |= (1<<i);}if(colum & (1<<j)){safe = 0;}else{colum |= (1<<j);}}}if(safe){printf("SAFE\n");}else{printf("NOT SAFE\n");}}}
- 南邮 OJ 1390 Rooks
- Light OJ 1005 Rooks
- 【瞎搞】 Light OJ 1005 - Rooks
- UVa OJ 11134 - Fabled Rooks
- light oj 1005 - Rooks(组合数学)
- Light OJ 1005 - Rooks 数学题解
- light oj 1005 - Rooks (组合数学)
- light oj 1005 Rooks(组合数)
- Rooks NOJ 1390
- Fabled Rooks
- A - Rooks
- Fabled Rooks
- Fabled Rooks
- HDU3160 Rooks
- UVA11134_Fabled Rooks
- Fabled Rooks
- A - Rooks
- uva 11134 Fabled Rooks
- UIImageview 点击事件 UITapGestureRecognizer传值
- UVALive - 4080 Warfare And Logistics (SPFA+最短路树)
- zoj1994 / poj2396 Budget 有上下界可行流求解
- makefile的编写总结
- 开启新篇章——软工视频总结
- 南邮 OJ 1390 Rooks
- hdu 5344 MZL's xor(水)
- HDOJ 1864 最大报销额(贪心)
- 第一篇博客
- 空气质量在线检测系统制作 之Smart Airbox 制作流程
- VelocityTracker简单用法
- listView.setLayoutParams
- iOS开发 ARC和MRC混编相关
- Jstat使用详解