Simple and easy, solved by two lines of python code.
ls = filter(lambda y: y, map(lambda x: x.strip(), raw_input()[1:-1].split(",")))
print len(set(ls))
Brute force. Just enumerate the beginning and the end of the substring, and …
more ...This problem is from the book "Algorithm 4th edition" (Exersise 4.1.10)
There are N cities and M undirected roads between those cities. People can travel to any city along the roads.
One day, a war breaks out. Our cities are under attack! As we can't defend all …
more ...Trun x => X
or X => x
to make the number of 'x' is equal to the number of 'X'.
n = int(raw_input())
hamsters = [c for c in raw_input()]
sits = hamsters.count('x')
stands = hamsters.count('X')
if sits == stands:
print 0
print ''.join(hamsters)
else:
if sits > stands …
It has been months that I didn't participate in the contest on CF, now I'm back. :)
This round of contest makes me confused that the problem B and C is a little bit too twisted, if you can't catch the vital point, you will get a lot of WAs …
more ...交错路:设P是图G的一条路,如果P的任意两条相邻的边一定是一条属于M而另一条不属于M,就称P是一条交错路。
通俗点来说,就是把一个图中的路径染成红黑两种。然后找出一条路,使这条路红黑 …
more ...水题,杠杆原理。
用^
把字符串分割开。然后分别计算两边的重量即可。
#Result: Dec 24, 2013 6:04:41 PM Wizmann A - Lever Python 2 Accepted 312 ms 4200 KB
def calc(ss …
将Array切片,然后按位统计某一位上1的个数C(1)和2的个数C(2)。然后在这一位上的操作数就为M = min(C(1), C(2))。
简单题
傻逼才错 …
more ...