# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
923753 | Isam | Anagramistica (COCI21_anagramistica) | C++17 | 1 ms | 604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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];
int get_cnt(int mask){
int 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;
}
return res;
}
inline void subtsk1(){
int ans(0);
for(int mask = 1; mask < (1 << n); ++mask){
ans += get_cnt(mask) == k;
}
cout << ans << '\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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |