Submission #3419702
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
for (auto it = v.begin();it != v.end();++it){
if(it != v.begin())os << " ";os << *it;
}return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
// typedef
typedef complex<double> Point;
// typedef pair<int, int> P;
// typedef pair<int, P> PP;
// typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int MAX = 3e3;
typedef pair<string, string> P;
string str;
map<P, int> mp;
signed main(){
int n;
cin >> n >> str;
rep(s,1<<n){
string s1 = "", s2 = "";
rep(j,n){
if(s & (1<<j))s1.pb(str[n+j]);
else s2.pb(str[n+j]);
}
reverse(all(s1));
reverse(all(s2));
mp[P(s2, s1)]++;
}
int ans = 0;
rep(s,1<<n){
string s1 = "", s2 = "";
rep(j,n){
if(s & (1<<j))s1.pb(str[j]);
else s2.pb(str[j]);
}
ans += mp[P(s1, s2)];
}
printf("%lld\n", ans);
return 0;
}
Submission Info
Submission Time |
|
Task |
C - String Coloring |
User |
Ryoga_0212 |
Language |
C++14 (GCC 5.4.1) |
Score |
600 |
Code Size |
2574 Byte |
Status |
AC |
Exec Time |
986 ms |
Memory |
87040 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 |
424 ms |
256 KB |
almost_z_1 |
AC |
434 ms |
256 KB |
almost_z_2 |
AC |
401 ms |
256 KB |
almost_z_3 |
AC |
427 ms |
256 KB |
bigrand_0 |
AC |
715 ms |
56704 KB |
bigrand_1 |
AC |
822 ms |
87040 KB |
bigrand_2 |
AC |
986 ms |
65408 KB |
example_0 |
AC |
1 ms |
256 KB |
example_1 |
AC |
5 ms |
384 KB |
example_2 |
AC |
1 ms |
256 KB |
example_3 |
AC |
395 ms |
256 KB |
handmade_0 |
AC |
1 ms |
256 KB |
handmade_1 |
AC |
1 ms |
256 KB |
nonzero_0 |
AC |
754 ms |
57600 KB |
nonzero_1 |
AC |
802 ms |
64128 KB |
nonzero_2 |
AC |
949 ms |
85632 KB |
nonzero_3 |
AC |
770 ms |
65280 KB |
nonzero_4 |
AC |
854 ms |
69120 KB |
nonzero_5 |
AC |
889 ms |
86656 KB |
nonzero_sc_0 |
AC |
393 ms |
256 KB |
nonzero_sc_1 |
AC |
549 ms |
3840 KB |
nonzero_sc_10 |
AC |
814 ms |
49024 KB |
nonzero_sc_11 |
AC |
694 ms |
34944 KB |
nonzero_sc_2 |
AC |
594 ms |
9600 KB |
nonzero_sc_3 |
AC |
668 ms |
26368 KB |
nonzero_sc_4 |
AC |
751 ms |
37760 KB |
nonzero_sc_5 |
AC |
822 ms |
57344 KB |
nonzero_sc_6 |
AC |
394 ms |
256 KB |
nonzero_sc_7 |
AC |
513 ms |
3200 KB |
nonzero_sc_8 |
AC |
574 ms |
8960 KB |
nonzero_sc_9 |
AC |
634 ms |
16640 KB |
nonzero_small_0 |
AC |
10 ms |
1536 KB |
nonzero_small_1 |
AC |
1 ms |
256 KB |
nonzero_small_2 |
AC |
1 ms |
256 KB |
nonzero_small_3 |
AC |
83 ms |
8192 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 |
526 ms |
3456 KB |
runnur_1 |
AC |
470 ms |
640 KB |
runnur_2 |
AC |
496 ms |
1152 KB |
runnur_3 |
AC |
484 ms |
1024 KB |
runnur_4 |
AC |
507 ms |
2560 KB |