Submission #24491271
Source Code Expand
#include<bits/stdc++.h>
#include<bits/extc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
using namespace __gnu_pbds;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t){
while(*sdbg != ',') { cerr<<*sdbg++; } cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef DEBUG
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<": "; for(auto i:x) cerr<<i<<" "; cerr<<endl;}}
#define debugr(l,r,x) {{cerr<<#x<<": "; for(int i=l;i<=r;i++) cerr<<x<<" "; cerr<<endl;}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debugr(l,r,x)
#define cerr while(0) cerr
#endif
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define int long long
typedef __int128 INT;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define priority_queue std::priority_queue
#define F first
#define S second
#define sz(x) (int)x.size()
#define rep(x,l,r) for(auto x=l; x<r; x++)
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
template <typename T> constexpr T fpow_eq(T& x, long long y, T identity = 1) {
for(; y > 0; x *= x, y >>= 1) if(y & 1) identity *= x;
return x = identity;
}
template <typename T> constexpr T fpow(T x, long long y, T identity = 1) { return fpow_eq(x, y, identity); }
template <int M, int PHI_M> struct modint {
static constexpr int MOD = M;
int val;
constexpr modint() : val(0) {}
constexpr modint(int x) : val(x % M) { val += val < 0 ? M : 0; }
constexpr modint(long long x) : modint(int(x % M)) {}
constexpr explicit operator int() const { return val; }
constexpr bool operator==(const modint& y) const { return val == y.val; }
constexpr bool operator!=(const modint& y) const { return val != y.val; }
constexpr modint& operator+=(const modint& y) { val += y.val; val -= val >= M ? M : 0; return *this; }
constexpr modint& operator-=(const modint& y) { val -= y.val; val += val < 0 ? M : 0; return *this; }
constexpr modint& operator*=(const modint& y) { val = ll(val) * y.val % M; return *this; }
constexpr modint& operator/=(const modint& y) { val = ll(val) * fpow(y, PHI_M - 1).val % M; return *this; }
constexpr modint& operator^=(ll y) { fpow_eq(*this, y); return *this; }
constexpr modint operator+(const modint& y) const { return modint(*this) += y; }
constexpr modint operator-(const modint& y) const { return modint(*this) -= y; }
constexpr modint operator*(const modint& y) const { return modint(*this) *= y; }
constexpr modint operator/(const modint& y) const { return modint(*this) /= y; }
constexpr modint operator^(ll y) const { return modint(*this) ^= y; }
constexpr modint operator-() const { return modint(0) -= *this; }
constexpr modint operator~() const { return modint(1) /= *this; }
constexpr modint& operator++() { val = val == M - 1 ? 0 : val + 1; return *this; }
constexpr modint& operator--() { val = val == 0 ? M - 1 : val - 1; return *this; }
constexpr modint operator++(int) { modint m = *this; ++(*this); return m; }
constexpr modint operator--(int) { modint m = *this; --(*this); return m; }
friend constexpr modint operator+(long long x, const modint& y) { return modint(x) + y; }
friend constexpr modint operator*(long long x, const modint& y) { return modint(x) * y; }
friend constexpr modint operator-(long long x, const modint& y) { return modint(x) - y; }
friend constexpr modint operator/(long long x, const modint& y) { return modint(x) / y; }
friend ostream& operator<<(ostream& os, const modint& m) { return os << m.val; }
friend istream& operator>>(istream& is, modint& m) { ll val; is >> val; m = modint(val); return is; }
};
using mint = modint<1000000007, 1000000006>;
mint dp[100005][9];
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string s;
cin>>s;
int n=sz(s);
map<char, int> mp;
string orig="chokudai";
for(int i=0; i<sz(orig); i++){
mp[orig[i]]=i+1;
}
dp[0][0]=1;
for(int i=1; i<=n; i++){
char cur=s[i-1];
for(int j=0; j<=8; j++){
dp[i][j] += dp[i-1][j];
}
if(mp[cur]>0) dp[i][mp[cur]] += dp[i-1][mp[cur]-1];
}
cout<<dp[n][8]<<endl;
}
Submission Info
| Submission Time |
|
| Task |
C - chokudai |
| User |
dsjong |
| Language |
C++ (GCC 9.2.1) |
| Score |
300 |
| Code Size |
4423 Byte |
| Status |
AC |
| Exec Time |
15 ms |
| Memory |
7272 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
300 / 300 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
example0.txt, example1.txt, example2.txt |
| All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, example0.txt, example1.txt, example2.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 000.txt |
AC |
7 ms |
3656 KiB |
| 001.txt |
AC |
5 ms |
3644 KiB |
| 002.txt |
AC |
2 ms |
3720 KiB |
| 003.txt |
AC |
2 ms |
3684 KiB |
| 004.txt |
AC |
3 ms |
3628 KiB |
| 005.txt |
AC |
2 ms |
3692 KiB |
| 006.txt |
AC |
2 ms |
3696 KiB |
| 007.txt |
AC |
3 ms |
3752 KiB |
| 008.txt |
AC |
12 ms |
7228 KiB |
| 009.txt |
AC |
13 ms |
7220 KiB |
| 010.txt |
AC |
15 ms |
7224 KiB |
| 011.txt |
AC |
14 ms |
7272 KiB |
| 012.txt |
AC |
12 ms |
7264 KiB |
| 013.txt |
AC |
13 ms |
7164 KiB |
| 014.txt |
AC |
13 ms |
7216 KiB |
| 015.txt |
AC |
15 ms |
7252 KiB |
| example0.txt |
AC |
2 ms |
3524 KiB |
| example1.txt |
AC |
3 ms |
3664 KiB |
| example2.txt |
AC |
3 ms |
3516 KiB |