답안 #83555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
83555 2018-11-09T07:29:47 Z XBXJLeiLeLeiLe Mate (COCI18_mate) PyPy
0 / 100
2000 ms 26784 KB
s = raw_input()
q = input()



def combination(n, d):
    k = d - 2
    result = 1
    for i in range(k):
        result*=n
        n-=1
    for i in range(k):
        result/=k
        k-=1
    return result
arr = []
for i in range(q):
    d, xy = raw_input().split()
    d = int(d)
    x = xy[0]
    y = xy[1]
    arr_l = []
    arr_c = []
    a = -1
    b = -1
    if x != y:
        for i in range(len(s)):
            if i >= d - 2 and s[i] == x:
                arr_l.append(i)
                arr_c.append(0)
                a = i
                b += 1
            elif len(arr_l)>0 and s[i]==y and i > a:
                for k in range(len(arr_c)):
                    arr_c[k] += 1
        for j in range(len(arr_l)):
            arr_l[j] = combination(arr_l[j], d)
        total = 0
        for i in range(len(arr_l)):
            total += arr_l[i]*arr_c[i]
        arr.append(total)
    else:
        for i in range(len(s)):
            if i >= d - 2 and s[i] == x:
                arr_l.append(i)
                for k in range(len(arr_c)):
                    arr_c[k] += 1
                arr_c.append(0)
        for j in range(len(arr_l)):
            arr_l[j] = combination(arr_l[j], d)
        total = 0
        for i in range(len(arr_l)):
            total += arr_l[i]*arr_c[i]
        arr.append(total)
for i in arr:
    print i
# 결과 실행 시간 메모리 Grader output
1 Incorrect 315 ms 24424 KB Output isn't correct
2 Incorrect 280 ms 24424 KB Output isn't correct
3 Incorrect 318 ms 24424 KB Output isn't correct
4 Incorrect 354 ms 26784 KB Output isn't correct
5 Execution timed out 2059 ms 26784 KB Time limit exceeded
6 Execution timed out 2053 ms 26784 KB Time limit exceeded
7 Execution timed out 2065 ms 26784 KB Time limit exceeded
8 Execution timed out 2045 ms 26784 KB Time limit exceeded
9 Execution timed out 2051 ms 26784 KB Time limit exceeded
10 Execution timed out 2053 ms 26784 KB Time limit exceeded