답안 #923897

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
923897 2024-02-08T05:13:35 Z Isam Anagramistica (COCI21_anagramistica) C++17
0 / 110
4 ms 20828 KB
#include<bits/stdc++.h>

#define speed ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define eb emplace_back
#define all(x) x.begin(), x.end()

using namespace std;

constexpr int sz = 2002;
const int mod = 1e9 + 7;

int n, k;
long long dp[sz], C[sz][sz];
string s;
unordered_map<string, int> cnt;

int main(){
	speed;
	cin >> n >> k;
	for(register int i = 1; i <= n; ++i){
		cin >> s;
		sort(all(s));
		cnt[s]++;
	}
	C[1][0] = C[1][1] = 1;
	for(register int i = 2; i <= n; ++i){
		for(register int j = 0; j <= i; ++j){
			if(!j){
				C[i][0] = 1;
				continue;
			}
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
			C[i][j] %= mod;
		}
	}
	dp[0] = 1;
	for(auto &to : cnt){
		int ai = to.second;
		for(register int i = k; i >= 1; --i){
			for(register int take = 1; take <= ai && C[take][2] <= i; ++take){
				dp[i] += 1ll * dp[i - C[take][2]] * C[ai][take] % mod;
				dp[i] %= mod;
			}
		}
	}
	cout << dp[k] % mod << '\n';
	return 0;
}

Compilation message

anagramistica.cpp: In function 'int main()':
anagramistica.cpp:20:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   20 |  for(register int i = 1; i <= n; ++i){
      |                   ^
anagramistica.cpp:26:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   26 |  for(register int i = 2; i <= n; ++i){
      |                   ^
anagramistica.cpp:27:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |   for(register int j = 0; j <= i; ++j){
      |                    ^
anagramistica.cpp:39:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   39 |   for(register int i = k; i >= 1; --i){
      |                    ^
anagramistica.cpp:40:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   40 |    for(register int take = 1; take <= ai && C[take][2] <= i; ++take){
      |                     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 20828 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -