Submission #1770951


Source Code Expand

// need
#include <iostream>
#include <algorithm>

// data structure
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
//#include <array>
//#include <unordered_map>
//#include <complex>
//#include <deque>
#include <valarray>

// stream
//#include <istream>
//#include <sstream>
//#include <ostream>
//#include <fstream>

// etc
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>

// input
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { std::cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { std::cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC_ROW(type, n, ...)std::vector<type> __VA_ARGS__;MACRO_VEC_ROW_Init(n, __VA_ARGS__); for(int i=0; i<n; ++i){MACRO_VEC_ROW_Scan(i, __VA_ARGS__);}
template<typename T> void MACRO_VEC_ROW_Init(int n, T& t) { t.resize(n); }
template<typename First, typename...Rest>void MACRO_VEC_ROW_Init(int n, First& first, Rest&...rest) { first.resize(n); MACRO_VEC_ROW_Init(n, rest...); }
template<typename T> void MACRO_VEC_ROW_Scan(int p, T& t) { std::cin >> t[p]; }
template<typename First, typename...Rest>void MACRO_VEC_ROW_Scan(int p, First& first, Rest&...rest) { std::cin >> first[p]; MACRO_VEC_ROW_Scan(p, rest...); }
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define MAT(type, c, m, n) std::vector<std::vector<type>> c(m, std::vector<type>(n));for(auto& r:c)for(auto& i:r)std::cin>>i;

// output
#define OUT(d) std::cout<<d;
#define FOUT(n, d) std::cout<<std::fixed<<std::setprecision(n)<<d;
#define SOUT(n, c, d) std::cout<<std::setw(n)<<std::setfill(c)<<d;
#define SP std::cout<<" ";
#define TAB std::cout<<"\t";
#define BR std::cout<<"\n";
#define SPBR(i, n) std::cout<<(i + 1 == n ? '\n' : ' ');
#define ENDL std::cout<<std::endl;
#define FLUSH std::cout<<std::flush;
#define SHOW(d) {std::cerr << #d << "\t:" << d << "\n";}
#define SHOWVECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOWVECTOR2(v) {std::cerr << #v << "\t:\n";for(const auto& xxx : v){for(const auto& yyy : xxx){std::cerr << yyy << " ";}std::cerr << "\n";}}
#define SHOWQUEUE(a) {auto tmp(a);std::cerr << #a << "\t:";while(!tmp.empty()){std::cerr << tmp.front() << " ";tmp.pop();}std::cerr << "\n";}

// utility
#define ALL(a) (a).begin(),(a).end()
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define FORLL(i, a, b) for(ll i=ll(a);i<ll(b);++i)
#define RFORLL(i, a, b) for(ll i=ll(b)-1;i>=ll(a);--i)
#define REPLL(i, n) for(ll i=0;i<ll(n);++i)
#define RREPLL(i, n) for(ll i=ll(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
template<typename T> inline T CHMAX(T& a, const T b) { return a = (a < b) ? b : a; }
template<typename T> inline T CHMIN(T& a, const T b) { return a = (a > b) ? b : a; }
#define EXCEPTION(msg) throw std::string("Exception : " msg " [ in ") + __func__ + " : " + std::to_string(__LINE__) + " lines ]"
#define TRY(cond, msg) try {if (cond) EXCEPTION(msg);}catch (std::string s) {std::cerr << s << std::endl;}
void CHECKTIME(std::function<void()> f) { auto start = std::chrono::system_clock::now(); f(); auto end = std::chrono::system_clock::now(); auto res = std::chrono::duration_cast<std::chrono::nanoseconds>((end - start)).count(); std::cerr << "[Time:" << res << "ns  (" << res / (1.0e9) << "s)]\n"; }

// test
template<class T> std::vector<std::vector<T>> VV(int n) {
	return std::vector<std::vector<T>>(n);
}
template<class T> std::vector<std::vector<T>> VV(int n, int m, T init = T()) {
	return std::vector<std::vector<T>>(n, std::vector<T>(m, init));
}
template<typename S, typename T>
std::ostream& operator<<(std::ostream& os, std::pair<S, T> p) {
	os << "(" << p.first << ", " << p.second << ")"; return os;
}

// type/const

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using PAIR = std::pair<int, int>;
using PAIRLL = std::pair<ll, ll>;
constexpr int INFINT = 1 << 30;                          // 1.07x10^ 9
constexpr int INFINT_LIM = (1LL << 31) - 1;              // 2.15x10^ 9
constexpr ll INFLL = 1LL << 60;                          // 1.15x10^18
constexpr ll INFLL_LIM = (1LL << 62) - 1 + (1LL << 62);  // 9.22x10^18
constexpr double EPS = 1e-9;
constexpr int MOD = 1000000007;
constexpr double PI = 3.141592653589793238462643383279;

int dp[1003];

signed main() {
	INIT;
	VAR(int, n);
	VAR(std::string, s);
	VEC_ROW(std::string, n, t);
	dp[0] = 1;
	REP(i, s.size()) {
		if (dp[i] == 0) continue;
		REP(j, n) {
			if (t[j] == s.substr(i, t[j].size())) {
				(dp[i + t[j].size()] += dp[i]) %= MOD;
			}
		}
	}
	OUT(dp[s.size()])BR;
	return 0;
}

Submission Info

Submission Time
Task B - エターナルスタティックファイナル
User satanic0258
Language C++14 (GCC 5.4.1)
Score 60
Code Size 5165 Byte
Status AC
Exec Time 10 ms
Memory 256 KB

Judge Result

Set Name All
Score / Max Score 60 / 60
Status
AC × 108
Set Name Test Cases
All 00_sample00.txt, 00_sample01.txt, 00_sample02.txt, 00_sample03.txt, 00_sample04.txt, 01_random00.txt, 01_random01.txt, 01_random02.txt, 01_random03.txt, 01_random04.txt, 01_random05.txt, 01_random06.txt, 01_random07.txt, 01_random08.txt, 01_random09.txt, 01_random10.txt, 01_random11.txt, 01_random12.txt, 01_random13.txt, 01_random14.txt, 01_random15.txt, 01_random16.txt, 01_random17.txt, 01_random18.txt, 01_random19.txt, 01_random20.txt, 01_random21.txt, 01_random22.txt, 01_random23.txt, 01_random24.txt, 01_random25.txt, 01_random26.txt, 01_random27.txt, 01_random28.txt, 01_random29.txt, 01_random30.txt, 01_random31.txt, 01_random32.txt, 01_random33.txt, 01_random34.txt, 01_random35.txt, 01_random36.txt, 01_random37.txt, 01_random38.txt, 01_random39.txt, 01_random40.txt, 01_random41.txt, 01_random42.txt, 01_random43.txt, 01_random44.txt, 01_random45.txt, 01_random46.txt, 01_random47.txt, 01_random48.txt, 01_random49.txt, 01_random50.txt, 01_random51.txt, 01_random52.txt, 01_random53.txt, 01_random54.txt, 01_random55.txt, 01_random56.txt, 01_random57.txt, 01_random58.txt, 01_random59.txt, 01_random61.txt, 01_random62.txt, 01_random63.txt, 01_random64.txt, 01_random65.txt, 01_random66.txt, 01_random67.txt, 01_random68.txt, 01_random69.txt, 01_random70.txt, 01_random71.txt, 01_random72.txt, 01_random73.txt, 01_random74.txt, 01_random75.txt, 01_random76.txt, 01_random77.txt, 01_random78.txt, 01_random79.txt, 01_random80.txt, 01_random81.txt, 01_random82.txt, 01_random83.txt, 01_random84.txt, 01_random85.txt, 01_random86.txt, 01_random87.txt, 01_random88.txt, 01_random89.txt, 01_random90.txt, 01_random91.txt, 01_random92.txt, 01_random93.txt, 01_random94.txt, 01_random95.txt, 01_random96.txt, 01_random97.txt, 01_random98.txt, 01_random99.txt, 02_manual00.txt, 02_manual01.txt, 02_manual02.txt, 02_manual03.txt
Case Name Status Exec Time Memory
00_sample00.txt AC 1 ms 256 KB
00_sample01.txt AC 1 ms 256 KB
00_sample02.txt AC 1 ms 256 KB
00_sample03.txt AC 1 ms 256 KB
00_sample04.txt AC 1 ms 256 KB
01_random00.txt AC 2 ms 256 KB
01_random01.txt AC 1 ms 256 KB
01_random02.txt AC 1 ms 256 KB
01_random03.txt AC 1 ms 256 KB
01_random04.txt AC 1 ms 256 KB
01_random05.txt AC 2 ms 256 KB
01_random06.txt AC 2 ms 256 KB
01_random07.txt AC 1 ms 256 KB
01_random08.txt AC 1 ms 256 KB
01_random09.txt AC 1 ms 256 KB
01_random10.txt AC 1 ms 256 KB
01_random11.txt AC 2 ms 256 KB
01_random12.txt AC 1 ms 256 KB
01_random13.txt AC 1 ms 256 KB
01_random14.txt AC 1 ms 256 KB
01_random15.txt AC 1 ms 256 KB
01_random16.txt AC 1 ms 256 KB
01_random17.txt AC 2 ms 256 KB
01_random18.txt AC 1 ms 256 KB
01_random19.txt AC 2 ms 256 KB
01_random20.txt AC 2 ms 256 KB
01_random21.txt AC 2 ms 256 KB
01_random22.txt AC 1 ms 256 KB
01_random23.txt AC 2 ms 256 KB
01_random24.txt AC 1 ms 256 KB
01_random25.txt AC 1 ms 256 KB
01_random26.txt AC 1 ms 256 KB
01_random27.txt AC 2 ms 256 KB
01_random28.txt AC 2 ms 256 KB
01_random29.txt AC 1 ms 256 KB
01_random30.txt AC 2 ms 256 KB
01_random31.txt AC 2 ms 256 KB
01_random32.txt AC 1 ms 256 KB
01_random33.txt AC 1 ms 256 KB
01_random34.txt AC 2 ms 256 KB
01_random35.txt AC 2 ms 256 KB
01_random36.txt AC 2 ms 256 KB
01_random37.txt AC 1 ms 256 KB
01_random38.txt AC 2 ms 256 KB
01_random39.txt AC 2 ms 256 KB
01_random40.txt AC 1 ms 256 KB
01_random41.txt AC 1 ms 256 KB
01_random42.txt AC 2 ms 256 KB
01_random43.txt AC 2 ms 256 KB
01_random44.txt AC 2 ms 256 KB
01_random45.txt AC 1 ms 256 KB
01_random46.txt AC 2 ms 256 KB
01_random47.txt AC 2 ms 256 KB
01_random48.txt AC 2 ms 256 KB
01_random49.txt AC 2 ms 256 KB
01_random50.txt AC 1 ms 256 KB
01_random51.txt AC 2 ms 256 KB
01_random52.txt AC 1 ms 256 KB
01_random53.txt AC 2 ms 256 KB
01_random54.txt AC 2 ms 256 KB
01_random55.txt AC 2 ms 256 KB
01_random56.txt AC 2 ms 256 KB
01_random57.txt AC 2 ms 256 KB
01_random58.txt AC 1 ms 256 KB
01_random59.txt AC 2 ms 256 KB
01_random61.txt AC 7 ms 256 KB
01_random62.txt AC 1 ms 256 KB
01_random63.txt AC 7 ms 256 KB
01_random64.txt AC 2 ms 256 KB
01_random65.txt AC 2 ms 256 KB
01_random66.txt AC 2 ms 256 KB
01_random67.txt AC 2 ms 256 KB
01_random68.txt AC 2 ms 256 KB
01_random69.txt AC 2 ms 256 KB
01_random70.txt AC 1 ms 256 KB
01_random71.txt AC 1 ms 256 KB
01_random72.txt AC 7 ms 256 KB
01_random73.txt AC 10 ms 256 KB
01_random74.txt AC 6 ms 256 KB
01_random75.txt AC 1 ms 256 KB
01_random76.txt AC 3 ms 256 KB
01_random77.txt AC 2 ms 256 KB
01_random78.txt AC 2 ms 256 KB
01_random79.txt AC 3 ms 256 KB
01_random80.txt AC 3 ms 256 KB
01_random81.txt AC 2 ms 256 KB
01_random82.txt AC 2 ms 256 KB
01_random83.txt AC 2 ms 256 KB
01_random84.txt AC 2 ms 256 KB
01_random85.txt AC 2 ms 256 KB
01_random86.txt AC 7 ms 256 KB
01_random87.txt AC 2 ms 256 KB
01_random88.txt AC 4 ms 256 KB
01_random89.txt AC 3 ms 256 KB
01_random90.txt AC 3 ms 256 KB
01_random91.txt AC 3 ms 256 KB
01_random92.txt AC 2 ms 256 KB
01_random93.txt AC 1 ms 256 KB
01_random94.txt AC 3 ms 256 KB
01_random95.txt AC 2 ms 256 KB
01_random96.txt AC 1 ms 256 KB
01_random97.txt AC 3 ms 256 KB
01_random98.txt AC 2 ms 256 KB
01_random99.txt AC 2 ms 256 KB
02_manual00.txt AC 8 ms 256 KB
02_manual01.txt AC 1 ms 256 KB
02_manual02.txt AC 1 ms 256 KB
02_manual03.txt AC 1 ms 256 KB