# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
135375 |
2019-07-24T04:27:52 Z |
이온조(#3249) |
PIN (CEOI10_pin) |
C++14 |
|
804 ms |
12512 KB |
#include <bits/stdc++.h>
using namespace std;
map<string, int> mp;
string S[50009];
string make(string S, int msk) {
for(int i=0; i<4; i++) if((msk >> i) & 1) S[i] = '_';
return S;
}
int main() {
cin.tie(0); cout.tie(0);
ios::sync_with_stdio(0);
int N, D; cin >> N >> D;
for(int i=1; i<=N; i++) {
cin >> S[i];
for(int j=1; j<16; j++) ++mp[make(S[i], j)];
}
for(auto& it: mp) --it.second;
long long ans = 0;
if(D == 1) {
for(int i=1; i<=N; i++) {
ans += mp[make(S[i], 1)];
ans += mp[make(S[i], 2)];
ans += mp[make(S[i], 4)];
ans += mp[make(S[i], 8)];
}
cout << ans / 2;
}
if(D == 2) {
for(int i=1; i<=N; i++) {
ans += mp[make(S[i], 3)];
ans += mp[make(S[i], 5)];
ans += mp[make(S[i], 9)];
ans += mp[make(S[i], 6)];
ans += mp[make(S[i], 10)];
ans += mp[make(S[i], 12)];
ans -= 3*mp[make(S[i], 1)];
ans -= 3*mp[make(S[i], 2)];
ans -= 3*mp[make(S[i], 4)];
ans -= 3*mp[make(S[i], 8)];
}
cout << ans / 2;
}
if(D == 3) {
for(int i=1; i<=N; i++) {
ans += mp[make(S[i], 14)];
ans += mp[make(S[i], 13)];
ans += mp[make(S[i], 11)];
ans += mp[make(S[i], 7)];
ans -= 2*mp[make(S[i], 3)];
ans -= 2*mp[make(S[i], 5)];
ans -= 2*mp[make(S[i], 9)];
ans -= 2*mp[make(S[i], 6)];
ans -= 2*mp[make(S[i], 10)];
ans -= 2*mp[make(S[i], 12)];
ans += 3*mp[make(S[i], 1)];
ans += 3*mp[make(S[i], 2)];
ans += 3*mp[make(S[i], 4)];
ans += 3*mp[make(S[i], 8)];
}
cout << ans / 2;
}
if(D == 4) {
for(int i=1; i<=N; i++) {
ans += mp[make(S[i], 15)];
ans -= mp[make(S[i], 14)];
ans -= mp[make(S[i], 13)];
ans -= mp[make(S[i], 11)];
ans -= mp[make(S[i], 7)];
ans += 2*mp[make(S[i], 3)];
ans += 2*mp[make(S[i], 5)];
ans += 2*mp[make(S[i], 9)];
ans += 2*mp[make(S[i], 6)];
ans += 2*mp[make(S[i], 10)];
ans += 2*mp[make(S[i], 12)];
ans -= 3*mp[make(S[i], 1)];
ans -= 3*mp[make(S[i], 2)];
ans -= 3*mp[make(S[i], 4)];
ans -= 3*mp[make(S[i], 8)];
}
cout << ans / 2;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
2424 KB |
Output is correct |
2 |
Correct |
15 ms |
2552 KB |
Output is correct |
3 |
Incorrect |
13 ms |
2552 KB |
Output isn't correct |
4 |
Correct |
111 ms |
3448 KB |
Output is correct |
5 |
Correct |
143 ms |
3452 KB |
Output is correct |
6 |
Correct |
177 ms |
3396 KB |
Output is correct |
7 |
Correct |
145 ms |
3448 KB |
Output is correct |
8 |
Correct |
152 ms |
3548 KB |
Output is correct |
9 |
Correct |
245 ms |
3448 KB |
Output is correct |
10 |
Correct |
347 ms |
3576 KB |
Output is correct |
11 |
Correct |
187 ms |
3576 KB |
Output is correct |
12 |
Correct |
378 ms |
3600 KB |
Output is correct |
13 |
Correct |
241 ms |
3584 KB |
Output is correct |
14 |
Incorrect |
218 ms |
3596 KB |
Output isn't correct |
15 |
Incorrect |
384 ms |
3676 KB |
Output isn't correct |
16 |
Correct |
300 ms |
10280 KB |
Output is correct |
17 |
Correct |
610 ms |
12512 KB |
Output is correct |
18 |
Incorrect |
498 ms |
10944 KB |
Output isn't correct |
19 |
Incorrect |
635 ms |
11940 KB |
Output isn't correct |
20 |
Incorrect |
804 ms |
12508 KB |
Output isn't correct |