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 ...
随机推荐
- (实用篇)PHP JSON数组与对象的理解
在PHP后端和客户端数据交互的过程中,JSON数据中有时格式不定,一会儿是数组,一会儿是对象,弄得客户端开发人员要崩溃的感觉. 因此,前后端相关人员先对PHP的json_encode函数原理有必要的了 ...
- linux/windows 下kill某个pid的进程
[linux环境] 方法1:截取进程pid,再kill ps -ef | grep java.endorsed.dirs | grep -v grep | cut -c10-15 | xargs ki ...
- 定时清理mysql数据。
Linux有一个非常好用的任务管理工具.crond.首先你得确认你这个服务是开启的. service crond start 并且设置为开机就启动. chkconfig --level crond o ...
- 矩阵基本运算的 Python 实现
from...import与import区别在于import直接导入指定的库,而from....import则是从指定的库中导入指定的模块 import...as则是将import A as B,给予 ...
- webrtc编译之libcommonaudio
[170/1600] CXX obj/webrtc/common_audio/common_audio.audio_util.o[171/1600] CXX obj/webrtc/common_aud ...
- zBoot/Makefile
#上层makefile调用执行make命令,执行的应该是第一个目标allHEAD = head.oSYSTEM = ../tools/zSystem#LD = gcc#TEST = -DTEST_DR ...
- c 深度剖析 3
1 typedef 和 define 的区别 #define是简单的替换; typedef是别名! 1 2 #define pchar char * pchar a,b;//展开后 char * ...
- java03实验截图
- URAL 1056 Computer Net(最短路)
Computer Net Time limit: 2.0 secondMemory limit: 64 MB Background Computer net is created by consecu ...
- Android—对话框
layout文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an ...