답안 #445065

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445065 2021-07-16T10:55:02 Z Karliver Trener (COCI20_trener) C++14
110 / 110
74 ms 8068 KB
	
 #include <bits/stdc++.h>
 
 #define FIXED_FLOAT(x)  std::fixed <<std::setprecision(20) << (x)
 #define all(v) (v).begin(), (v).end()
 using namespace  std;
 #define forn(i,n) for (int i = 0; i < (n); ++i)
 #define rforn(i, n) for(int i = (n) - 1;i >= 0;--i)
 using ll = long long;
 int mod = (ll)1e9 + 7;
 #define PI acos(-1)
 typedef pair<int, int> pairs;
 
 const int INF = 1e9 + 1;
 const int N = 2e5 + 100;
 const double eps = 1e-7;
 
 template <class T> using V = vector<T>;  
 template <class T> using VV = V<V<T>>;  
 
 template <typename XPAX>
 void ckma(XPAX &x, XPAX y) {
     x = (x < y ? y : x);
 }
 template <typename XPAX>
 void ckmi(XPAX &x, XPAX y) {
     x = (x > y ? y : x);
 }
 void __print(int x) {cerr << x;}
 void __print(long x) {cerr << x;}
 void __print(long long x) {cerr << x;}
 void __print(unsigned x) {cerr << x;}
 void __print(unsigned long x) {cerr << x;}
 void __print(unsigned long long x) {cerr << x;}
 void __print(float x) {cerr << x;}
 void __print(double x) {cerr << x;}
 void __print(long double x) {cerr << x;}
 void __print(char x) {cerr << '\'' << x << '\'';}
 void __print(const char *x) {cerr << '\"' << x << '\"';}
 void __print(const string &x) {cerr << '\"' << x << '\"';}
 void __print(bool x) {cerr << (x ? "true" : "false");}
 
 template<typename T, typename V>
 void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
 template<typename T>
 void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
 void _print() {cerr << "]\n";}
 template <typename T, typename... V>
 void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
 #define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
 void solve() {
 
 
 	unordered_map<string, int> ps;


 	int n, k;
 	cin >> n >> k;

 	VV<string> s(n + 1);

 	forn(i, n) {
 		forn(j, k) {
 			string lr;
 			cin >> lr;
 			//debug(lr);
 			s[i].push_back(lr);
 		}
 	}
 	//debug(s);
 	for(auto c : s[0])
 		ps[c] += 1;

 	//debug(ps);

 	for(int i = 1;i < n;++i) {
 		unordered_map<string, int> dp;
 		for(auto t : s[i]) {
 			string one = t.substr(0, i);
 			string two = t.substr(1, i);
 			int x = ps[one];
 			if(one != two) {
 				x += ps[two];
 				x %= mod;
 			}
 			dp[t] += x;
 			dp[t] %= mod;
 		}
 		swap(ps, dp);
 		//debug(ps);
 	}

 	int ans = 0;

 	for(auto t : ps) {
 		ans += t.second;
 		ans %= mod;
 	}
 	cout << ans << '\n';

 
 
 
 }
 void test_case() {
     int t;
     cin >> t;
     forn(p, t) {
 
         //cout << "Case #" << p + 1 << ": ";
         solve();
     }
 }
 int main() {
 
     ios::sync_with_stdio(false);
     cin.tie(0);
 
     solve();
 
 }
  
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 716 KB Output is correct
2 Correct 5 ms 844 KB Output is correct
3 Correct 5 ms 832 KB Output is correct
4 Correct 3 ms 716 KB Output is correct
5 Correct 5 ms 844 KB Output is correct
6 Correct 4 ms 844 KB Output is correct
7 Correct 4 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 5 ms 716 KB Output is correct
6 Correct 5 ms 844 KB Output is correct
7 Correct 5 ms 832 KB Output is correct
8 Correct 3 ms 716 KB Output is correct
9 Correct 5 ms 844 KB Output is correct
10 Correct 4 ms 844 KB Output is correct
11 Correct 4 ms 716 KB Output is correct
12 Correct 74 ms 8020 KB Output is correct
13 Correct 73 ms 7988 KB Output is correct
14 Correct 71 ms 8008 KB Output is correct
15 Correct 73 ms 8068 KB Output is correct
16 Correct 34 ms 7332 KB Output is correct
17 Correct 59 ms 7848 KB Output is correct
18 Correct 72 ms 7856 KB Output is correct
19 Correct 61 ms 7880 KB Output is correct
20 Correct 62 ms 7816 KB Output is correct
21 Correct 60 ms 7896 KB Output is correct
22 Correct 33 ms 7372 KB Output is correct