[Offer收割]编程练习赛28 register

Ended

Participants:277

Verdict:Accepted
Score:100 / 100
Submitted:2017-09-24 13:27:43

Lang:Python2

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
T = int(raw_input())
for t in range(T):
    time = raw_input().strip()
    nums = set()
    for t in time:
        if '0' <= t <= '9':
            nums.add(t)
    def possible(nums):
        res = []
        # print nums
        
        for h0 in nums:
            for h1 in nums:
                res.append(h0 + h1)
        res.sort()
        return res
    
    pos_times = possible(nums)
    hms = time.split(':')
    si = pos_times.index(s)
    if si+1 < len(pos_times) and int(pos_times[si+1]) <= 59:
        print h + ':' + m + ':' + pos_times[si+1]
        continue
    mi = pos_times.index(m)
    if mi+1 < len(pos_times) and int(pos_times[mi+1]) <= 59:
        print h + ':' + pos_times[mi+1] + ':' + pos_times[0]
        continue
    hi = pos_times.index(h)
    if hi+1 < len(pos_times) and int(pos_times[hi+1]) <= 23:
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX