HackerRank "Vertical Rooks"
Please note: VROOK cannot go back-ward - that leads to a simple variation to Game of Nim: just XOR.
t = int(input())
for _ in range(t):
n = int(input())
# Get input
p1 = []
for _ in range(n): p1.append(int(input()))
p2 = []
for _ in range(n): p2.append(int(input()))
# Game of Nim
nim = 0
for i in range(n):
nim ^= abs(p2[i]- p1[i]) - 1
print ("player-2" if nim != 0 else "player-1")
HackerRank "Vertical Rooks"的更多相关文章
- VK Cup 2015 - Round 1 E. Rooks and Rectangles 线段树 定点修改,区间最小值
E. Rooks and Rectangles Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemse ...
- Vertical Menu ver4
以前一直使div来创建Vertical菜单,也曾有过3个版本.http://www.cnblogs.com/insus/archive/2011/10/19/2217314.html 现今Insus. ...
- [LeetCode] Binary Tree Vertical Order Traversal 二叉树的竖直遍历
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bott ...
- UVA - 11134 Fabled Rooks[贪心 问题分解]
UVA - 11134 Fabled Rooks We would like to place n rooks, 1 ≤ n ≤ 5000, on a n × n board subject to t ...
- LeetCode Binary Tree Vertical Order Traversal
原题链接在这里:https://leetcode.com/problems/binary-tree-vertical-order-traversal/ 题目: Given a binary tree, ...
- 日常小测:颜色 && Hackerrank Unique_colors
题目传送门:https://www.hackerrank.com/challenges/unique-colors 感谢hzq大神找来的这道题. 考虑点分治(毕竟是路经统计),对于每一个颜色,它的贡献 ...
- Binary Tree Vertical Order Traversal
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bott ...
- HackerRank "Square Subsequences" !!!
Firt thought: an variation to LCS problem - but this one has many tricky detail. I learnt the soluti ...
- HackerRank "Minimum Penalty Path"
It is about how to choose btw. BFS and DFS. My init thought was to DFS - TLE\MLE. And its editorial ...
随机推荐
- 一次性编译所有T-Code
SGEN, 然后选择Generate all,或regenerate ...... 转的,My question: 这个不太懂能干什么
- php 小知识积累
1.如果能将类的方法定义成static,就尽量定义成static,它的速度会提升将近4倍. 2.$row['id']的速度是$row[id]的7倍. 3.echo比print快,并且使用echo的多重 ...
- 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) J dp 背包
J. Bottles time limit per test 2 seconds memory limit per test 512 megabytes input standard input ou ...
- Educational Codeforces Round 15 A dp
A. Maximum Increase time limit per test 1 second memory limit per test 256 megabytes input standard ...
- ZOJ 1024 Calendar Game
原题链接 题目大意:2001年11月4日是一个黄道吉日,有两个人做游戏,看谁先数到这个日子.可以往后数一天,比如2号到3号,30号到31号,也可以往后数一个月.给出一个起始的日子,求能否保证先开始游戏 ...
- 使用Matlab对灰度图像编程实现2D的傅里叶变换
1. 先载入一幅灰度图像,如下: (非灰度图) 2. 利用函数fft2,对其进行快速傅立叶变换, 并利用函数fftshift 将变换后的图像原点移动到频率矩形的中心. 3. 利用abs()函 ...
- SpringMVC 自定义参数绑定实现日期类型绑定
package cn.itcast.ssm.controller.converter; import java.text.ParseException; import java.text.Simple ...
- Codeforces Round #134 (Div. 2)
A. Mountain Scenery 枚举山顶位置,满足\(r_{i-1} \lt r_i - 1 \gt r_{i+1}\). 范围要开\(2N\). B. Airport 优先队列维护最值. C ...
- 后台向前台传递entity的list然后构筑combobox的方法(easyui)
遇问题,莫着急,深呼吸. 后台写法:JsonUtil.toJson(new ArrayList<Entity>());此处jsonUtil是已封装的方法,即将entity的list转为js ...
- poj2553 强连通
题意:定义了一个图的底(bottom),是指在一个图中能够被所有点到达的点,问途中有哪些点是图的底. 首先是同一个强连通分量中的点都能够互相到达,强连通分量中一个点能到达其他点,也必然代表该强连通分量 ...