Submission #69676150
Source Code Expand
//#include "atcoder/modint" #pragma GCC optimize("Ofast") #include "atcoder/all" #include <bits/stdc++.h> #include <string> using namespace std; using namespace atcoder; #define int long long template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; } //const int MOD =1e9+7; //constexpr int MOD =10; constexpr int MOD =998244353; const long long M1=167772161,M2=469762049,M3=1224736769; //const int MOD =31607; using mint = static_modint<MOD>; //using mint = double; //using mint = modint; ostream& operator << (ostream& ost, const mint& m){ost << m.val();return ost;} istream& operator >> (istream& ost, mint& m){int a;ost >> a;m=a;return ost;} double time_limit = 100.0,start_temp=0.01,end_temp=0.0; std::mt19937 rng(std::random_device{}()); mint dp[1ll<<22]={}; signed main(){ //ios_base::sync_with_stdio(false); //cin.tie(NULL); int n; string t; cin>>n>>t; dp[0]=1; for(int i=0;i<(1ll<<n);i++){ char c='-'; for(int j=0;j<n;j++)if(((i&(1ll<<j))==0)&&(t[j]!=c)){ c=t[j]; dp[i|(1ll<<j)]+=dp[i]; } } cout<<dp[(1ll<<n)-1]<<endl; }
Submission Info
Submission Time | |
---|---|
Task | F - Inserting Process |
User | yatuba |
Language | C++ 20 (gcc 12.2) |
Score | 500 |
Code Size | 1348 Byte |
Status | AC |
Exec Time | 296 ms |
Memory | 20068 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_test_00.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt, 01_test_18.txt, 01_test_19.txt, 01_test_20.txt, 01_test_21.txt, 01_test_22.txt, 01_test_23.txt, 01_test_24.txt, 01_test_25.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_sample_00.txt | AC | 10 ms | 19972 KiB |
00_sample_01.txt | AC | 10 ms | 19904 KiB |
00_sample_02.txt | AC | 271 ms | 19964 KiB |
01_test_00.txt | AC | 10 ms | 20032 KiB |
01_test_01.txt | AC | 10 ms | 19944 KiB |
01_test_02.txt | AC | 141 ms | 19940 KiB |
01_test_03.txt | AC | 10 ms | 19884 KiB |
01_test_04.txt | AC | 11 ms | 19880 KiB |
01_test_05.txt | AC | 296 ms | 19816 KiB |
01_test_06.txt | AC | 279 ms | 19904 KiB |
01_test_07.txt | AC | 281 ms | 20012 KiB |
01_test_08.txt | AC | 278 ms | 19900 KiB |
01_test_09.txt | AC | 273 ms | 19944 KiB |
01_test_10.txt | AC | 273 ms | 20032 KiB |
01_test_11.txt | AC | 272 ms | 20028 KiB |
01_test_12.txt | AC | 267 ms | 19952 KiB |
01_test_13.txt | AC | 272 ms | 20008 KiB |
01_test_14.txt | AC | 270 ms | 19964 KiB |
01_test_15.txt | AC | 270 ms | 20032 KiB |
01_test_16.txt | AC | 273 ms | 20068 KiB |
01_test_17.txt | AC | 274 ms | 19900 KiB |
01_test_18.txt | AC | 273 ms | 19904 KiB |
01_test_19.txt | AC | 273 ms | 19976 KiB |
01_test_20.txt | AC | 273 ms | 19960 KiB |
01_test_21.txt | AC | 272 ms | 19936 KiB |
01_test_22.txt | AC | 287 ms | 19948 KiB |
01_test_23.txt | AC | 281 ms | 19900 KiB |
01_test_24.txt | AC | 269 ms | 19940 KiB |
01_test_25.txt | AC | 10 ms | 19904 KiB |