Bitwise

UVa 10032. Tug of War

Description N個人參加拔河比賽,每個人有其重量w[i],欲使二隊的人數最多只差一,雙方的重量和越接近越好。請問二隊的重量和分別是多少?
2018-08-11

CodeForces. Round 502

比賽連結:CodeForces Round #502 以下為我個人的解法,在優化上不一定做得很好。
2018-08-09

UVa 10952. Pattern Transformations

Description Consider the two patterns of ‘O’ and ‘X’ below (‘.’ represent an empty square). We want the first pattern to be transformed into the second pattern in one time unit. During this time unit, each symbol (‘O’ and ‘X’) can move one step in any of the four directions (or remain at its current square). All movements happen simultaneously, so a symbol can move to an occupied square, if that symbol is moved to some other square. If a symbol moves from square A to B, and the symbol at B moves to A, we have a swap. Write a program which calculates the least number of swaps needed to transform a given pattern into another given pattern.
2018-08-06