Submission #923806

#TimeUsernameProblemLanguageResultExecution timeMemory
923806IsamAnagramistica (COCI21_anagramistica)C++17
10 / 110
6 ms11612 KiB
#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; const int sz = 1001, mod = 1e9 + 7; int n, k, cnt(1); int C[sz][sz]; string s; unordered_map<string, int> mp; unordered_map<int, int> a; long long dp[sz][sz]; int main(){ speed; cin >> n >> k; for(register int i = 1; i <= n; ++i){ cin >> s; sort(all(s)); if(!mp[s]) mp[s] = cnt++; a[mp[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; } } int m = (int)a.size(); auto it = a.begin(); dp[0][0] = 1; for(register int i = 1; i <= m; ++i){ int ai = it->second; for(register int j = k; j >= 0; --j){ for(register int l = 0; l <= ai && C[l][2] <= j; ++l){ dp[i][j] += 1ll * C[ai][l] * dp[i-1][j - C[l][2]] % mod; dp[i][j] %= mod; } } ++it; } cout << dp[m][k] << '\n'; return 0; }

Compilation message (stderr)

anagramistica.cpp: In function 'int main()':
anagramistica.cpp:26:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   26 |  for(register int i = 1; i <= n; ++i){
      |                   ^
anagramistica.cpp:33:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |  for(register int i = 2; i <= n; ++i){
      |                   ^
anagramistica.cpp:34:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   34 |   for(register int j = 0; j <= i; ++j){
      |                    ^
anagramistica.cpp:41:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   41 |  for(register int i = 1; i <= m; ++i){
      |                   ^
anagramistica.cpp:43:20: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   43 |   for(register int j = k; j >= 0; --j){
      |                    ^
anagramistica.cpp:44:21: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   44 |    for(register int l = 0; l <= ai && C[l][2] <= j; ++l){
      |                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...