Submission #923755

# Submission time Handle Problem Language Result Execution time Memory
923755 2024-02-07T17:35:12 Z Isam Anagramistica (COCI21_anagramistica) C++17
10 / 110
12 ms 600 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;

const int sz = 1001, mod = 1e9 + 7;

int n, k, a[sz];

string s[sz];

long long get_cnt(int mask){
	long long res(0);
	unordered_map<int, int> cnt;
	for(register int i = 1; i <= n; ++i){
		if(mask & (1 << (i - 1))) cnt[a[i]]++;
	}
	for(auto &to : cnt){
		res += to.second * (to.second - 1) / 2;
		if(res >= mod) res -= mod;
	}
	return (res + mod) % mod;
}

inline void subtsk1(){
	int ans(0);
	for(int mask = 0; mask < (1 << n); ++mask){
		ans += get_cnt(mask) == k;
		ans %= mod;
	}
	cout << ans % mod << '\n';
}

map<string, int> mp;

int cntl(1);

int main(){
	speed;
	cin >> n >> k;
	for(register int i = 1; i <= n; ++i){
		cin >> s[i];
		sort(all(s[i]));
		if(!mp[s[i]]) mp[s[i]] = cntl++;
		a[i] = mp[s[i]];
	}
	subtsk1();
	return 0;
}

Compilation message

anagramistica.cpp: In function 'long long int get_cnt(int)':
anagramistica.cpp:18:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   18 |  for(register int i = 1; i <= n; ++i){
      |                   ^
anagramistica.cpp: In function 'int main()':
anagramistica.cpp:44:19: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   44 |  for(register int i = 1; i <= n; ++i){
      |                   ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 12 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 4 ms 348 KB Output is correct
4 Correct 5 ms 348 KB Output is correct
5 Correct 12 ms 356 KB Output is correct
6 Runtime error 1 ms 600 KB Execution killed with signal 11
7 Halted 0 ms 0 KB -