Submission #2843156


Source Code Expand

Copy
/**
 *    author:  tourist
 *    created: 14.07.2018 15:20:06       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int half;
  cin >> half;
  string s;
  cin >> s;
  map<string,int> mp;
  for (int t = 0; t < (1 << half); t++) {
    string a = "", b = "";
    for (int i = 0; i < half; i++) {
      if (t & (1 << i)) {
        a += s[i];
      } else {
        b += s[i];
      }
    }
    string c = a + "." + string(b.rbegin(), b.rend());
    mp[c]++;
  }
  long long ans = 0;
  for (int t = 0; t < (1 << half); t++) {
    string a = "", b = "";
    for (int i = 0; i < half; i++) {
      if (t & (1 << i)) {
        a += s[i + half];
      } else {
        b += s[i + half];
      }
    }
    string c = string(a.rbegin(), a.rend()) + "." + b;
    ans += mp[c];
  }
  cout << ans << '\n';
  return 0;
}

Submission Info

Submission Time
Task C - String Coloring
User tourist
Language C++14 (GCC 5.4.1)
Score 600
Code Size 915 Byte
Status AC
Exec Time 676 ms
Memory 67968 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 4
AC × 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 AC 471 ms 256 KB
almost_z_1 AC 415 ms 384 KB
almost_z_2 AC 429 ms 256 KB
almost_z_3 AC 409 ms 256 KB
bigrand_0 AC 587 ms 44672 KB
bigrand_1 AC 672 ms 67968 KB
bigrand_2 AC 600 ms 52096 KB
example_0 AC 1 ms 256 KB
example_1 AC 4 ms 384 KB
example_2 AC 1 ms 256 KB
example_3 AC 430 ms 256 KB
handmade_0 AC 1 ms 256 KB
handmade_1 AC 1 ms 256 KB
nonzero_0 AC 602 ms 44544 KB
nonzero_1 AC 607 ms 51200 KB
nonzero_2 AC 676 ms 66816 KB
nonzero_3 AC 604 ms 50944 KB
nonzero_4 AC 636 ms 52864 KB
nonzero_5 AC 664 ms 67712 KB
nonzero_sc_0 AC 394 ms 256 KB
nonzero_sc_1 AC 468 ms 2944 KB
nonzero_sc_10 AC 593 ms 39040 KB
nonzero_sc_11 AC 561 ms 27136 KB
nonzero_sc_2 AC 483 ms 7808 KB
nonzero_sc_3 AC 543 ms 20992 KB
nonzero_sc_4 AC 560 ms 32128 KB
nonzero_sc_5 AC 621 ms 44288 KB
nonzero_sc_6 AC 386 ms 256 KB
nonzero_sc_7 AC 537 ms 2432 KB
nonzero_sc_8 AC 489 ms 7296 KB
nonzero_sc_9 AC 567 ms 13440 KB
nonzero_small_0 AC 9 ms 1280 KB
nonzero_small_1 AC 1 ms 256 KB
nonzero_small_2 AC 1 ms 256 KB
nonzero_small_3 AC 72 ms 6400 KB
rand_0 AC 1 ms 256 KB
rand_1 AC 1 ms 256 KB
rand_2 AC 1 ms 256 KB
runnur_0 AC 458 ms 2944 KB
runnur_1 AC 504 ms 640 KB
runnur_2 AC 439 ms 896 KB
runnur_3 AC 488 ms 896 KB
runnur_4 AC 449 ms 2048 KB