답안 #447905

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
447905 2021-07-28T06:15:31 Z Jasiekstrz Anagramistica (COCI21_anagramistica) C++17
110 / 110
30 ms 37704 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=2e3;
const int MOD=1e9+7;
map<string,int> cnt;
int t[N+10];
long long ch[N+10][N+10];
long long dp[N+10][N+10];
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		cnt[s]++;
	}
	ch[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		ch[i][0]=1;
		for(int j=1;j<=n;j++)
			ch[i][j]=(ch[i-1][j-1]+ch[i-1][j])%MOD;
	}
	n=0;
	for(auto &v:cnt)
		t[++n]=v.se;
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			for(int l=0;l<=t[i] && ch[l][2]<=j;l++)
				dp[i][j]=(dp[i][j]+dp[i-1][j-ch[l][2]]*ch[t[i]][l])%MOD;
		}
	}
	cout<<dp[n][k]<<"\n";
	return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 12 ms 17740 KB Output is correct
2 Correct 18 ms 25168 KB Output is correct
3 Correct 20 ms 27980 KB Output is correct
4 Correct 25 ms 33096 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 12 ms 17740 KB Output is correct
7 Correct 18 ms 25168 KB Output is correct
8 Correct 20 ms 27980 KB Output is correct
9 Correct 25 ms 33096 KB Output is correct
10 Correct 6 ms 7244 KB Output is correct
11 Correct 4 ms 5708 KB Output is correct
12 Correct 10 ms 12552 KB Output is correct
13 Correct 9 ms 12492 KB Output is correct
14 Correct 17 ms 24832 KB Output is correct
15 Correct 17 ms 24140 KB Output is correct
16 Correct 30 ms 37704 KB Output is correct
17 Correct 28 ms 32080 KB Output is correct
18 Correct 24 ms 32804 KB Output is correct