GitHub GraphQL API [Quick Start](新手友好)

由于软工项目选的是社交好友分析,又得捡起爬虫的那一套理论。。。社交好友分析应用数据才是王道,没有数据就没有发言权。写一个稳定的爬虫还是很重要的。准备爬github的时候发现github已经不再使用REST API,而是用的一个叫GraphQL API的东西。github上的教程在,但是把这一套教程从头到尾看完花了我几个小时,于是想在这里写一个快速上手教程。

Hint:github GraphQL API 网页版测试工具 很好用,侧面还有文档,可以随时查,很方便

继续阅读“GitHub GraphQL API [Quick Start](新手友好)”




2017ICPC北京网络赛 G | hihocoder 1584 Bounce

For Argo, it is very interesting watching a circle bouncing in a rectangle.

As shown in the figure below, the rectangle is divided into N×M grids, and the circle fits exactly one grid.

The bouncing rule is simple:

1. The circle always starts from the left upper corner and moves towards lower right.

2. If the circle touches any edge of the rectangle, it will bounce.

3. If the circle reaches any corner of the rectangle after starting, it will stop there.

Argo wants to know how many grids the circle will go through only once until it first reaches another corner. Can you help him?
继续阅读“2017ICPC北京网络赛 G | hihocoder 1584 Bounce”

2017ICPC北京网络赛 B | hihocoder 1579 Reverse Suffix Array


There is a strong data structure called “Suffix Array” which can effectively solve string problems.

Let S=s1s2…sn be a string and let S[i,j] denote the substring of S ranging from i to j. The suffix array A of S is now defined to be an array of integers providing the starting positions of suffixes of S in lexicographical order. This means, an entry A[i] is the starting position of the i-th smallest suffix in S and thus for all 1 < i ≤ n:  S[A[i-1], n] < S[A[i], n].

For example: the suffix array of “banana” is [6, 4, 2, 1, 5, 3].

Here comes another problem called “Reverse Suffix Array”.

Given a suffix array, you need to figure out how many lower case strings are there whose suffix array is the same as the given suffix array.
继续阅读“2017ICPC北京网络赛 B | hihocoder 1579 Reverse Suffix Array”