Submission #923894

# Submission time Handle Problem Language Result Execution time Memory
923894 2024-02-08T05:09:30 Z Isam Anagramistica (COCI21_anagramistica) C++17
0 / 110
20 ms 42332 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){
			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 >= 0; ++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:35:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   35 |   for(register int i = k; i >= 0; ++i){
      |                    ^
anagramistica.cpp:36:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   36 |    for(register int take = 1; take <= ai && C[take][2] <= i; ++take){
      |                     ^~~~
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 20 ms 42332 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -