Submission #2845141


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;

int main(){
    long long i, j, k;
    long long N;
    cin >> N;
    string S;
    cin >> S;

    map<string, long long> hash1[20];
    for(i=0; i<(1<<N); i++){
        string str1 = "";
        string str2 = "";
        long long ones = 0;
        for(j=0; j<N; j++){
            if((i>>j) & 1){
                str1 += S[j];
                ones += 1;
            }else{
                str2 += S[j];
            }
        }
        reverse(str2.begin(), str2.end());
        string key = str1 + str2;
        hash1[ones][key] += 1;
    }

    long long ans = 0;
    for(i=0; i<(1<<N); i++){
        string str1 = "";
        string str2 = "";
        long long ones = 0;
        for(j=0; j<N; j++){
            if((i>>j) & 1){
                str1 += S[N+j];
                ones += 1;
            }else{
                str2 += S[N+j];
            }
        }
        reverse(str1.begin(), str1.end());
        string key = str1 + str2;
        ans += hash1[ones][key];
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task C - String Coloring
User betrue12
Language C++14 (GCC 5.4.1)
Score 600
Code Size 1115 Byte
Status
Exec Time 652 ms
Memory 68224 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_0, example_1, example_2, example_3
All 600 / 600 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 372 ms 256 KB
almost_z_1 378 ms 256 KB
almost_z_2 363 ms 256 KB
almost_z_3 370 ms 256 KB
bigrand_0 574 ms 44672 KB
bigrand_1 645 ms 68224 KB
bigrand_2 586 ms 51584 KB
example_0 1 ms 256 KB
example_1 4 ms 384 KB
example_2 1 ms 256 KB
example_3 353 ms 256 KB
handmade_0 1 ms 256 KB
handmade_1 1 ms 256 KB
nonzero_0 583 ms 45056 KB
nonzero_1 591 ms 50560 KB
nonzero_2 652 ms 67200 KB
nonzero_3 583 ms 51200 KB
nonzero_4 609 ms 53888 KB
nonzero_5 645 ms 67968 KB
nonzero_sc_0 353 ms 256 KB
nonzero_sc_1 430 ms 3072 KB
nonzero_sc_10 634 ms 38656 KB
nonzero_sc_11 528 ms 27392 KB
nonzero_sc_2 479 ms 7552 KB
nonzero_sc_3 509 ms 20864 KB
nonzero_sc_4 529 ms 29824 KB
nonzero_sc_5 630 ms 44800 KB
nonzero_sc_6 361 ms 256 KB
nonzero_sc_7 431 ms 2560 KB
nonzero_sc_8 445 ms 7168 KB
nonzero_sc_9 509 ms 13184 KB
nonzero_small_0 10 ms 1152 KB
nonzero_small_1 1 ms 256 KB
nonzero_small_2 1 ms 256 KB
nonzero_small_3 67 ms 6016 KB
rand_0 1 ms 256 KB
rand_1 1 ms 256 KB
rand_2 1 ms 256 KB
runnur_0 424 ms 3072 KB
runnur_1 391 ms 640 KB
runnur_2 403 ms 1024 KB
runnur_3 407 ms 896 KB
runnur_4 417 ms 2176 KB