Submission #3046253
Source Code Expand
#include <iostream> #include <fstream> #include <cmath> #include <cstdlib> #include <ctime> #include <algorithm> #include <numeric> #include <functional> #include <string> #include <vector> #include <bitset> #include <map> #include <set> #include <stack> #include <queue> #include <deque> using namespace std; using ll = long long; using ull = unsigned long long; using ld = long double; #define REP(i,n) for(int i = 0; i < int(n); i++) #define REREP(i,n) for(int i = int(n - 1); i >= 0; i--) #define FOR(i, m, n) for(int i = int(m);i < int(n);i++) #define REFOR(i, m, n) for(int i = int(n - 1);i >= int(m);i--) #define ALL(obj) (obj).begin(),(obj).end() #define fi first #define se second #define VI vector<int> #define VVI vector<vector<int>> #define VVVI vector<vector<vector<int>>> #define VD vector<double> #define VVD vector<vector<double>> #define VVVD vector<vector<vector<double>>> #define VL vector<ll> #define VVL vector<vector<ll>> #define VVVL vector<vector<vector<ll>>> #define VB vector<bool> #define VVB vector<vector<bool>> #define VVVB vector<vector<vector<bool>>> #define VS vector<string> #define VVS vector<vector<string>> #define VVVS vector<vector<vector<string>>> #define PII pair<int,int> #define PDD pair<double,double> #define PLL pair<ll,ll> #define VPII vector<pair<int,int>> #define VVPII vector<vector<pair<int,int>>> #define VVVPII vector<vector<vector<pair<int,int>>>> #define VPLL vector<pair<ll,ll>> #define VVPLL vector<vector<pair<ll,ll>>> #define VVVPLL vector<vector<vector<pair<ll,ll>>>> const ll MOD = (ll)1e9 + 7; const ll HINF = (ll)1e18; const ll LINF = (ll)1e9; const long double PI = 3.1415926535897932384626433; void YN(bool flag) { cout << ((flag) ? "YES" : "NO") << endl; } void Yn(bool flag) { cout << ((flag) ? "Yes" : "No") << endl; } void yn(bool flag) { cout << ((flag) ? "yes" : "no") << endl; } int main() { int N; cin >> N; string S,T; cin >> T; S = T.substr(0, N); T = T.substr(N, N); reverse(ALL(T)); map<pair<string, string>, ll> mp,mpS,mpT; REP(i, 1 << N) { string SR, SB, TR, TB; REP(j, N) ((i & 1 << j) ? SR : SB) += S[j]; REP(j, N) ((i & 1 << j) ? TR : TB) += T[j]; mp[{SR, SB}] = mp[{TR, TB}] = 1; mpS[{SR, SB}]++; mpT[{TR, TB}]++; } ll ans = 0; for (auto p : mp) ans += mpS[p.first] * mpT[p.first]; cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - String Coloring |
User | ningenMe |
Language | C++14 (GCC 5.4.1) |
Score | 600 |
Code Size | 2441 Byte |
Status | AC |
Exec Time | 2356 ms |
Memory | 157440 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 600 / 600 | ||||
Status |
|
|
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 | 513 ms | 256 KB |
almost_z_1 | AC | 551 ms | 384 KB |
almost_z_2 | AC | 446 ms | 256 KB |
almost_z_3 | AC | 502 ms | 256 KB |
bigrand_0 | AC | 1690 ms | 103296 KB |
bigrand_1 | AC | 2356 ms | 157440 KB |
bigrand_2 | AC | 1899 ms | 120192 KB |
example_0 | AC | 1 ms | 256 KB |
example_1 | AC | 7 ms | 640 KB |
example_2 | AC | 1 ms | 256 KB |
example_3 | AC | 429 ms | 256 KB |
handmade_0 | AC | 1 ms | 256 KB |
handmade_1 | AC | 1 ms | 256 KB |
nonzero_0 | AC | 1731 ms | 103424 KB |
nonzero_1 | AC | 1910 ms | 118144 KB |
nonzero_2 | AC | 2306 ms | 155904 KB |
nonzero_3 | AC | 1835 ms | 118144 KB |
nonzero_4 | AC | 1928 ms | 123008 KB |
nonzero_5 | AC | 2230 ms | 157056 KB |
nonzero_sc_0 | AC | 430 ms | 256 KB |
nonzero_sc_1 | AC | 786 ms | 6784 KB |
nonzero_sc_10 | AC | 1719 ms | 90112 KB |
nonzero_sc_11 | AC | 1404 ms | 64896 KB |
nonzero_sc_2 | AC | 887 ms | 17536 KB |
nonzero_sc_3 | AC | 1242 ms | 48256 KB |
nonzero_sc_4 | AC | 1460 ms | 69248 KB |
nonzero_sc_5 | AC | 1800 ms | 103040 KB |
nonzero_sc_6 | AC | 423 ms | 256 KB |
nonzero_sc_7 | AC | 714 ms | 5504 KB |
nonzero_sc_8 | AC | 886 ms | 16384 KB |
nonzero_sc_9 | AC | 1067 ms | 30976 KB |
nonzero_small_0 | AC | 20 ms | 2560 KB |
nonzero_small_1 | AC | 2 ms | 256 KB |
nonzero_small_2 | AC | 1 ms | 256 KB |
nonzero_small_3 | AC | 170 ms | 14464 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 | 690 ms | 8832 KB |
runnur_1 | AC | 626 ms | 1280 KB |
runnur_2 | AC | 642 ms | 2432 KB |
runnur_3 | AC | 637 ms | 2304 KB |
runnur_4 | AC | 678 ms | 6144 KB |