# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
136844 | choikiwon | PIN (CEOI10_pin) | C++17 | 438 ms | 19512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int maxn = 50010;
int N, D;
string pin[maxn];
int bcnt[16];
map<string, vector<string> > V[16];
map<string, int> cnt[16];
int main() {
std::ios::sync_with_stdio(false);
for(int i = 0; i < 16; i++) {
for(int j = 0; j < 4; j++) if(i & (1 << j)) bcnt[i]++;
}
cin >> N >> D;
D = 4 - D;
for(int i = 0; i < N; i++) {
cin >> pin[i];
}
for(int i = 0; i < N; i++) {
for(int j = 0; j < 16; j++) {
if(bcnt[j] != D) continue;
string x, y;
for(int k = 0; k < 4; k++) {
if(j & (1 << k)) x.push_back(pin[i][k]);
else y.push_back(pin[i][k]);
}
V[j][x].push_back(y);
}
}
int ans = 0;
for(int mask = 0; mask < 16; mask++) {
if(bcnt[mask] != D) continue;
for(auto it = V[mask].begin(); it != V[mask].end(); it++) {
for(int i = 0; i < (1 << (4 - D)); i++) cnt[i].clear();
vector<string> X = it->second;
for(int i = 0; i < X.size(); i++) {
for(int j = 0; j < (1 << (4 - D)); j++) {
string x;
for(int k = 0; k < 4; k++) if(j & (1 << k)) x.push_back(X[i][k]);
cnt[j][x]++;
}
}
for(int m = 0; m < 16; m++) {
for(auto it = cnt[m].begin(); it != cnt[m].end(); it++) {
if(bcnt[m] % 2) ans -= 1LL * it->second * (it->second - 1) / 2;
else ans += 1LL * it->second * (it->second - 1) / 2;
}
}
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |