Submission #4620000


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main(){
  int N;
  string S;
  cin >> N >> S;
  vector<map<string,int>> mp(N+1);
  for(int i = 0; i < (1<<N); ++i){
    string A(N,'?');
    int a = 0, b = 0;
    for(int j = 0; j < N; ++j){
      if((i>>j)&1) A[a++] = S[j];
      else A[N-1-b++] = S[j];
    }
    ++mp[a][A];
  }
  long long ans = 0;
  for(int i = 0; i < (1<<N); ++i){
    string A(N,'?');
    int a = 0, b = 0;
    for(int j = 0; j < N; ++j){
      if((i>>j)&1) A[a++] = S[2*N-1-j];
      else A[N-1-b++] = S[2*N-1-j];
    }
    ans += mp[a][A];
  }
  cout << ans << endl;
}

Submission Info

Submission Time
Task C - String Coloring
User TAB
Language C++14 (GCC 5.4.1)
Score 600
Code Size 654 Byte
Status
Exec Time 555 ms
Memory 65792 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
× 4
× 43
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 89 ms 256 KB
almost_z_1 91 ms 256 KB
almost_z_2 88 ms 256 KB
almost_z_3 90 ms 256 KB
bigrand_0 382 ms 43264 KB
bigrand_1 555 ms 65792 KB
bigrand_2 348 ms 50304 KB
example_0 1 ms 256 KB
example_1 2 ms 384 KB
example_2 1 ms 256 KB
example_3 82 ms 256 KB
handmade_0 1 ms 256 KB
handmade_1 1 ms 256 KB
nonzero_0 352 ms 43264 KB
nonzero_1 357 ms 49408 KB
nonzero_2 434 ms 64768 KB
nonzero_3 336 ms 49408 KB
nonzero_4 368 ms 51456 KB
nonzero_5 438 ms 65536 KB
nonzero_sc_0 82 ms 256 KB
nonzero_sc_1 153 ms 2944 KB
nonzero_sc_10 333 ms 37632 KB
nonzero_sc_11 274 ms 26368 KB
nonzero_sc_2 171 ms 7424 KB
nonzero_sc_3 228 ms 20224 KB
nonzero_sc_4 273 ms 29056 KB
nonzero_sc_5 335 ms 43008 KB
nonzero_sc_6 82 ms 256 KB
nonzero_sc_7 135 ms 2432 KB
nonzero_sc_8 168 ms 7040 KB
nonzero_sc_9 208 ms 12928 KB
nonzero_small_0 5 ms 1152 KB
nonzero_small_1 1 ms 256 KB
nonzero_small_2 1 ms 256 KB
nonzero_small_3 37 ms 5632 KB
rand_0 1 ms 256 KB
rand_1 1 ms 256 KB
rand_2 1 ms 256 KB
runnur_0 145 ms 2816 KB
runnur_1 111 ms 512 KB
runnur_2 130 ms 896 KB
runnur_3 130 ms 896 KB
runnur_4 135 ms 2048 KB