답안 #464066

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
464066 2021-08-12T10:33:41 Z Jasiekstrz Trener (COCI20_trener) C++17
110 / 110
189 ms 18140 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int MOD=1e9+7;
map<string,int> dp;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	long long ans=0;
	dp[""]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			string s;
			cin>>s;
			if(i==n)
				ans=(ans-dp[s])%MOD;
			string s1=s,s2=s;
			s1.pop_back();
			s2.erase(s2.begin());
			dp[s]=((long long)dp[s]+dp[s1]+(s1!=s2)*dp[s2])%MOD;
			if(i==n)
				ans=(ans+dp[s])%MOD;
		}
	}
	cout<<(ans+MOD)%MOD<<"\n";
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1356 KB Output is correct
2 Correct 10 ms 1332 KB Output is correct
3 Correct 9 ms 1304 KB Output is correct
4 Correct 2 ms 312 KB Output is correct
5 Correct 8 ms 1100 KB Output is correct
6 Correct 8 ms 1100 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 9 ms 1356 KB Output is correct
6 Correct 10 ms 1332 KB Output is correct
7 Correct 9 ms 1304 KB Output is correct
8 Correct 2 ms 312 KB Output is correct
9 Correct 8 ms 1100 KB Output is correct
10 Correct 8 ms 1100 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 175 ms 18088 KB Output is correct
13 Correct 174 ms 18104 KB Output is correct
14 Correct 189 ms 18124 KB Output is correct
15 Correct 184 ms 18140 KB Output is correct
16 Correct 32 ms 2244 KB Output is correct
17 Correct 140 ms 12736 KB Output is correct
18 Correct 144 ms 12944 KB Output is correct
19 Correct 142 ms 12828 KB Output is correct
20 Correct 143 ms 12928 KB Output is correct
21 Correct 141 ms 12864 KB Output is correct
22 Correct 37 ms 2336 KB Output is correct