# |
제출 시각 |
아이디 |
문제 |
언어 |
결과 |
실행 시간 |
메모리 |
778944 |
2023-07-11T04:20:41 Z |
이동현(#10002) |
PIN (CEOI10_pin) |
C++17 |
|
187 ms |
16300 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define int long long
using namespace std;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, d;
cin >> n >> d;
vector<map<string, int>> mp(16);
vector<string> a(n);
for(int i = 0; i < n; ++i){
cin >> a[i];
for(int j = 0; j < 16; ++j){
string now;
for(int k = 0; k < 4; ++k){
if(j & (1 << k)){
now += a[i][k];
}
}
++mp[j][now];
}
}
vector<int> sum(16);
for(int i = 0; i < 16; ++i){
for(auto&j:mp[i]){
sum[i] += j.second * (j.second - 1) / 2;
}
}
auto sol = [&](int x){
vector<int> st;
if(x == 4) st = {1, 2, 4, 8};
else if(x == 3) st = {3, 5, 9, 6, 10, 12};
else if(x == 2) st = {7, 11, 13, 14};
else st = {15};
int rv = n * (n - 1) / 2;
int sz = (1 << (int)st.size());
for(int i = 1; i < sz; ++i){
int bt = 0;
for(int j = 0; j < (int)st.size(); ++j){
if(i & (1 << j)){
bt |= st[j];
}
}
int op = (__builtin_popcount(i) % 2 ? -1 : 1);
rv += op * sum[bt];
}
return rv;
};
cout << sol(d) - (d != 4 ? sol(d + 1) : 0) << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
1108 KB |
Output is correct |
2 |
Correct |
4 ms |
980 KB |
Output is correct |
3 |
Correct |
3 ms |
852 KB |
Output is correct |
4 |
Correct |
42 ms |
3904 KB |
Output is correct |
5 |
Correct |
52 ms |
4544 KB |
Output is correct |
6 |
Correct |
51 ms |
4524 KB |
Output is correct |
7 |
Correct |
47 ms |
3952 KB |
Output is correct |
8 |
Correct |
56 ms |
4856 KB |
Output is correct |
9 |
Correct |
96 ms |
6792 KB |
Output is correct |
10 |
Correct |
109 ms |
7284 KB |
Output is correct |
11 |
Correct |
56 ms |
4684 KB |
Output is correct |
12 |
Correct |
121 ms |
7004 KB |
Output is correct |
13 |
Correct |
68 ms |
5108 KB |
Output is correct |
14 |
Correct |
57 ms |
4748 KB |
Output is correct |
15 |
Correct |
98 ms |
7064 KB |
Output is correct |
16 |
Correct |
119 ms |
12236 KB |
Output is correct |
17 |
Correct |
187 ms |
16300 KB |
Output is correct |
18 |
Correct |
144 ms |
13424 KB |
Output is correct |
19 |
Correct |
167 ms |
15028 KB |
Output is correct |
20 |
Correct |
183 ms |
16252 KB |
Output is correct |