0w1

Entries from 2016-03-06 to 1 day

UVA 1608 Non-boring sequences ( DC )

UVa Online Judge It is obvious that once we find an element that is "non-boring", we can split segment to two sub segments to apply divide and conquer for each. The problem is that if we try to find that "non-boring" element from either si…

UVA 11214 Guarding the Chessboard ( IDDFS )

UVa Online Judge Store the information of a queen set by the row, column and both diagonals it occupies in order to accelerate the search. A little prune used is to skip decisions that will not occupy any line. #include <bits/stdc++.h> using namespace st</bits/stdc++.h>…

TOIJ 1014 打地鼠 ( bitset DP )

1014 - 打地鼠 | TIOJ INFOR Online Judge 挺水的。O( ( n ^ 2 ) * ( 2 ^ n ) ) #include <bits/stdc++.h> using namespace std; const int MAXN = 16 + 2; const int MAXA = 1e8 + 8; const int INF = 2e9; int n; int a[ MAXN ]; int dp[ MAXN ][ 1 << MAXN ]; // last hi</bits/stdc++.h>…

TIOJ 1291 N箱M球 ( DP )

1291 - G.N 箱M 球 | TIOJ INFOR Online Judge dp[ m ][ n ]: m顆球放入 n個箱子,每個箱子至少有一樣東西 這麼一來轉移就很明顯,因為只有球有序所以很好做,轉移要嘛就是丟進一個新的箱子,要嘛就選一個已經有球的箱子,這樣不會有重複計算。一開始我把邊…

CFR Gym FB Hacker Cup Qualification Round

http://codeforces.com/gym/100869 pA. Quite trivial, just take combination of distances. #include <bits/stdc++.h> using namespace std; typedef pair<int, int> pii; const double EPS = 1e-8; vector<pii> star; double sqr(double k){ return k * k; } double dis(int a, int b){ </pii></int,></bits/stdc++.h>…

CFR 450 B. Jzzhu and Sequences ( Adhoc or Fast matrix multiplication )

Problem - B - Codeforces Well, though it did not take me much time, it is really silly that I did not realize the sequence will eventually become periodic, thus it is possible to write a solution in less then 10 lines with O( 1 ) time comp…