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.appe…
E. Rooks and Rectangles Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset/problem/524/E Description Polycarpus has a chessboard of size n × m, where k rooks are placed. Polycarpus hasn't yet invented the rules of the game…
以前一直使div来创建Vertical菜单,也曾有过3个版本.http://www.cnblogs.com/insus/archive/2011/10/19/2217314.html 现今Insus.NET抛开DIV标签生成的方法,使用a标签,而且是能动态添加的Vertical的网站左边菜单条.为了能够动态管理,莫非是把菜单的信息存储于数据库中,在网站的后管理页面能够添加,编辑,更新及删除这些菜单的信息. SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON…
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column). If two nodes are in the same row and column, the order should be from left to right. Examples: Given binary tree [3,9,20,null,n…
UVA - 11134 Fabled Rooks We would like to place n rooks, 1 ≤ n ≤ 5000, on a n × n board subject to the following restrictions The i-th rook can only be placed within the rectan- gle given by its left-upper corner (xli,yli) and its right- lower corner…
原题链接在这里:https://leetcode.com/problems/binary-tree-vertical-order-traversal/ 题目: Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column). If two nodes are in the same row and column, th…
Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column). If two nodes are in the same row and column, the order should be from left to right. Examples:Given binary tree [3,9,20,null,nu…
Firt thought: an variation to LCS problem - but this one has many tricky detail. I learnt the solution from this link:https://github.com/wangyongliang/Algorithm/blob/master/hackerrank/Strings/Square%20Subsequences/main.cc And here is his code with my…
It is about how to choose btw. BFS and DFS. My init thought was to DFS - TLE\MLE. And its editorial gives a very neat BFS based idea which costs much less memory. https://www.hackerrank.com/challenges/beautiful-path/editorial…
It is marked as a NPC problem. However from the #1 code submission (https://www.hackerrank.com/CharlesOfria), it looks pretty much like a Brutal-Force (or simulation) based solution, mixed with some greedy strategies. To me the other NPC "Queens Revi…
http://www.lightoj.com/volume_showproblem.php?problem=1005 PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB A rook is a piece used in the game of chess which is played on a board of square grids. A rook can only move…
We would like to place n rooks, 1 n 5000, on a n nboard subject to the following restrictions• The i-th rook can only be placed within the rectan-gle given by its left-upper corner (xli; yli) and its right-lower corner (xri; yri), where 1 i n, 1 xli…
传送门 今天在HackerRank上翻到一道高精度题,于是乎就写了个高精度的模板,说是模板其实就只有乘法而已. Extra long factorials Authored by vatsalchanana on Jun 16 2015 Problem Statement You are given an integer N. Print the factorial of this number. N!=N×(N−1)×(N−2)×⋯×3×2×1 Note: Factorials of N>20…
Great learning for me:https://www.hackerrank.com/rest/contests/master/challenges/lucky-numbers/hackers/turuthok/download_solution Basically it is memorized search application. And we follow a discrete strategy: split it into digits and go digit by di…
This is 'Difficult' - I worked out it within 45mins, and unlocked HackerRank Algorithm Level 80 yeah! So the idea is straight forward: 1. sort the input array and calculate partial_sum()2. find the negative\positive boundary with the accumulated give…
A sly knapsack problem in disguise! Thanks to https://github.com/bhajunsingh/programming-challanges/tree/master/hackerrank/algorithms/the-indian-jobLesson learnt: The Italian\Indian job is two-way 01 Knapsack. And some complext problem can be convert…
The most interesting, flexible and juicy binary tree problem I have ever seen. I learnt it from here: https://codepair.hackerrank.com/paper/5fIoGg74?b=eyJyb2xlIjoiY2FuZGlkYXRlIiwibmFtZSI6IkJsdWVCaXJkMjI0IiwiZW1haWwiOiJoZWFsdGh5dG9ueUBnbWFpbC5jb20ifQ%…
Something to learn: Rotation ops in AVL tree does not require recursion. https://github.com/andreimaximov/hacker-rank/blob/master/data-structures/tree/self-balancing-tree/main.cpp node *create_node(int val) { node *pNew = new node; pNew->val = val; p…
these days, I am compelting vertical sync https://msdn.microsoft.com/zh-cn/library/windows/desktop/bb172585(v=vs.85).aspx D3DPRESENT_INTERVAL_DEFAULT This is nearly equivalent to D3DPRESENT_INTERVAL_ONE. See remarks. D3DPRESENT_INTERVAL_ONE The dri…
题目: Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom, column by column). If two nodes are in the same row and column, the order should be from left to right. Examples:Given binary tree [3,9,20,nul…
Problem F: Fabled Rooks We would like to place n rooks, 1 ≤ n ≤ 5000, on a n×n board subject to the following restrictions The i-th rook can only be placed within the rectangle given by its left-upper corner (xli, yli) and its right-lower corner (xri…
https://www.hackerrank.com/contests/infinitum-aug14/challenges/jim-beam 学习了线段相交的判断法.首先是叉乘,叉乘的几何意义是有向的平行四边形的面积(除以2就是三角形的面积).如果ABD和ABC正负相反,说明C和D在AB两侧,同样的,再判断A和B是否在CD两侧即可.当某三角形面积为0时,需要判断是否在线段上. #include <iostream> using namespace std; typedef long long…
https://www.hackerrank.com/challenges/service-lane 用RMQ做的,其实暴力也能过~ #include <iostream> #include <vector> #include <cmath> using namespace std; int main() { int n, t; cin >> n >> t; vector<int> vec(n); for (int i = 0; i…
https://www.hackerrank.com/contests/w1/challenges/maximizing-xor/ 找了半天规律,答案竟然是暴力,伤感.我找到的方法是利用规律2^x XOR 2^x - 1会最大,感觉稍微效率高点. int maxXor(int l, int r) { if (l == r) return 0; int p = 1; for (int i = 0; i <= 10; i++) { if (p * 2 > r) break; p *= 2; } i…