Submission #69682942
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 998244353;
unordered_map<string,int> mp;
int calc (const string& s_org) {
if (mp.find(s_org)!=mp.end()) return mp[s_org];
int result = 0;
unordered_set<string> st;
string s = s_org;
char c = s.back();
s.pop_back();
for (int i=s.size(); i>=0; i--) {
if (i<s.size()) swap(c,s.at(i));
if (st.count(s)==1) continue;
st.emplace(s);
result += calc(s);
result %= mod;
}
mp.emplace(s_org,result);
return result;
}
/////////////////// メイン ///////////////////
int main () {
//////////////////// 入力 ////////////////////
int n;
string t;
cin >> n >> t;
mp[""] = 1;
//////////////// 出力変数定義 ////////////////
int result = 0;
//////////////////// 処理 ////////////////////
calc(t);
result = mp.at(t);
//////////////////// 出力 ////////////////////
cout << result << endl;
//////////////////// 終了 ////////////////////
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - Inserting Process |
| User | wightou |
| Language | C++ 23 (gcc 12.2) |
| Score | 0 |
| Code Size | 1063 Byte |
| Status | TLE |
| Exec Time | 2764 ms |
| Memory | 96688 KiB |
Compile Error
Main.cpp: In function ‘int calc(const std::string&)’:
Main.cpp:19:10: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
19 | if (i<s.size()) swap(c,s.at(i));
| ~^~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 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 | 1 ms | 3660 KiB |
| 00_sample_01.txt | AC | 1 ms | 3516 KiB |
| 00_sample_02.txt | TLE | 2764 ms | 96328 KiB |
| 01_test_00.txt | AC | 1 ms | 3524 KiB |
| 01_test_01.txt | AC | 1 ms | 3688 KiB |
| 01_test_02.txt | AC | 21 ms | 4896 KiB |
| 01_test_03.txt | AC | 1 ms | 3560 KiB |
| 01_test_04.txt | AC | 1 ms | 3636 KiB |
| 01_test_05.txt | AC | 1 ms | 3524 KiB |
| 01_test_06.txt | AC | 42 ms | 6000 KiB |
| 01_test_07.txt | AC | 50 ms | 6332 KiB |
| 01_test_08.txt | AC | 254 ms | 18652 KiB |
| 01_test_09.txt | AC | 701 ms | 34072 KiB |
| 01_test_10.txt | AC | 1797 ms | 65552 KiB |
| 01_test_11.txt | TLE | 2764 ms | 93656 KiB |
| 01_test_12.txt | AC | 2284 ms | 76592 KiB |
| 01_test_13.txt | AC | 1429 ms | 54020 KiB |
| 01_test_14.txt | AC | 1788 ms | 66644 KiB |
| 01_test_15.txt | TLE | 2764 ms | 92704 KiB |
| 01_test_16.txt | TLE | 2764 ms | 93208 KiB |
| 01_test_17.txt | TLE | 2764 ms | 91476 KiB |
| 01_test_18.txt | TLE | 2764 ms | 96688 KiB |
| 01_test_19.txt | AC | 122 ms | 9488 KiB |
| 01_test_20.txt | AC | 2474 ms | 73584 KiB |
| 01_test_21.txt | TLE | 2763 ms | 85172 KiB |
| 01_test_22.txt | AC | 1 ms | 3536 KiB |
| 01_test_23.txt | AC | 1 ms | 3644 KiB |
| 01_test_24.txt | AC | 2 ms | 3720 KiB |
| 01_test_25.txt | AC | 1 ms | 3424 KiB |