Submission #3044660


Source Code Expand

import itertools
N=int(input())
S=input()
ans=0
L=dict()
R=dict()
for seq in itertools.product([0,1],repeat=N):
    T0=""
    T1=""
    T2=""
    T3=""
    for i in range(N):
        if seq[i]==0:
            T0+=S[i]
            T2+=S[-i-1]
        else:
            T1+=S[i]
            T3+=S[-i-1]
    a0=len(T0)
    a1=len(T1)
    a2=len(T2)
    a3=len(T3)
    L[(T0,T1)]=L.get((T0,T1),0)+1
    R[(T2,T3)]=R.get((T2,T3),0)+1
for tup in L:
    if tup in R:
        ans+=L[tup]*R[tup]
print(ans)

Submission Info

Submission Time
Task C - String Coloring
User shakayami
Language Python (3.4.3)
Score 0
Code Size 526 Byte
Status TLE
Exec Time 3162 ms
Memory 125812 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 600
Status
AC × 4
AC × 39
TLE × 4
Set Name Test Cases
Sample example_0, example_1, example_2, example_3
All almost_z_0, almost_z_1, almost_z_2, almost_z_3, bigrand_0, bigrand_1, bigrand_2, example_0, example_1, example_2, example_3, handmade_0, handmade_1, nonzero_0, nonzero_1, nonzero_2, nonzero_3, nonzero_4, nonzero_5, nonzero_sc_0, nonzero_sc_1, nonzero_sc_10, nonzero_sc_11, nonzero_sc_2, nonzero_sc_3, nonzero_sc_4, nonzero_sc_5, nonzero_sc_6, nonzero_sc_7, nonzero_sc_8, nonzero_sc_9, nonzero_small_0, nonzero_small_1, nonzero_small_2, nonzero_small_3, rand_0, rand_1, rand_2, runnur_0, runnur_1, runnur_2, runnur_3, runnur_4
Case Name Status Exec Time Memory
almost_z_0 AC 2806 ms 3064 KB
almost_z_1 AC 2680 ms 3064 KB
almost_z_2 AC 2692 ms 3064 KB
almost_z_3 AC 2713 ms 3064 KB
bigrand_0 AC 2952 ms 85704 KB
bigrand_1 AC 2968 ms 125792 KB
bigrand_2 TLE 3075 ms 96432 KB
example_0 AC 17 ms 3064 KB
example_1 AC 32 ms 3316 KB
example_2 AC 17 ms 3064 KB
example_3 AC 2687 ms 3064 KB
handmade_0 AC 17 ms 3064 KB
handmade_1 AC 17 ms 3064 KB
nonzero_0 AC 2958 ms 85716 KB
nonzero_1 AC 2949 ms 95112 KB
nonzero_2 TLE 3162 ms 125812 KB
nonzero_3 AC 2991 ms 101312 KB
nonzero_4 TLE 3074 ms 98220 KB
nonzero_5 TLE 3133 ms 125812 KB
nonzero_sc_0 AC 2707 ms 3064 KB
nonzero_sc_1 AC 2641 ms 8712 KB
nonzero_sc_10 AC 2940 ms 79384 KB
nonzero_sc_11 AC 2926 ms 54504 KB
nonzero_sc_2 AC 2724 ms 19536 KB
nonzero_sc_3 AC 2818 ms 42204 KB
nonzero_sc_4 AC 2847 ms 55348 KB
nonzero_sc_5 AC 2957 ms 85744 KB
nonzero_sc_6 AC 2682 ms 3064 KB
nonzero_sc_7 AC 2702 ms 7512 KB
nonzero_sc_8 AC 2767 ms 16080 KB
nonzero_sc_9 AC 2823 ms 28420 KB
nonzero_small_0 AC 50 ms 4980 KB
nonzero_small_1 AC 18 ms 3064 KB
nonzero_small_2 AC 18 ms 3064 KB
nonzero_small_3 AC 337 ms 15140 KB
rand_0 AC 17 ms 3064 KB
rand_1 AC 17 ms 3064 KB
rand_2 AC 17 ms 3064 KB
runnur_0 AC 2796 ms 12580 KB
runnur_1 AC 2701 ms 4312 KB
runnur_2 AC 2795 ms 5492 KB
runnur_3 AC 2672 ms 5380 KB
runnur_4 AC 2690 ms 10264 KB