# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
154738 | 2019-09-24T11:12:35 Z | arnold518 | PIN (CEOI10_pin) | C++14 | 162 ms | 2936 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 5e4; int N, D; int A[MAXN+10][5], T[5]={1, 40, 40*40, 40*40*40}; ll ans[5]; int f(char x) { if('0'<=x && x<='9') return x-'0'; else return x-'a'+10; } void solve() { int i, j, k, p, q; for(i=0; i<4; i++) { map<int, int> M; for(j=1; j<=N; j++) { ans[1]+=M[A[j][4]-A[j][i]]; M[A[j][4]-A[j][i]]++; } } for(i=0; i<4; i++) { for(j=i+1; j<4; j++) { map<int, int> M; for(k=1; k<=N; k++) { ans[2]+=M[A[k][4]-A[k][i]-A[k][j]]; M[A[k][4]-A[k][i]-A[k][j]]++; } } } ans[2]-=ans[1]*3; for(i=0; i<4; i++) { map<int, int> M; for(j=1; j<=N; j++) { ans[3]+=M[A[j][i]]; M[A[j][i]]++; } } ans[3]-=2*ans[2]-3*ans[1]; ans[4]=(ll)N*(N-1)/2; map<int, int> M; for(i=1; i<=N; i++) { ans[4]-=M[A[j][4]]; M[A[j][4]]++; } } int main() { int i, j; scanf("%d%d", &N, &D); for(i=1; i<=N; i++) { char s[5]; scanf("%s", s); A[i][0]=f(s[0])*T[0]; A[i][1]=f(s[1])*T[1]; A[i][2]=f(s[2])*T[2]; A[i][3]=f(s[3])*T[3]; A[i][4]=A[i][0]+A[i][1]+A[i][2]+A[i][3]; } solve(); printf("%lld", ans[D]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 376 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Incorrect | 4 ms | 248 KB | Output isn't correct |
4 | Correct | 37 ms | 888 KB | Output is correct |
5 | Correct | 45 ms | 1040 KB | Output is correct |
6 | Correct | 45 ms | 1016 KB | Output is correct |
7 | Correct | 42 ms | 888 KB | Output is correct |
8 | Correct | 50 ms | 1132 KB | Output is correct |
9 | Correct | 78 ms | 1404 KB | Output is correct |
10 | Correct | 86 ms | 1500 KB | Output is correct |
11 | Correct | 50 ms | 1016 KB | Output is correct |
12 | Incorrect | 82 ms | 1400 KB | Output isn't correct |
13 | Incorrect | 52 ms | 1016 KB | Output isn't correct |
14 | Incorrect | 48 ms | 888 KB | Output isn't correct |
15 | Incorrect | 81 ms | 1400 KB | Output isn't correct |
16 | Correct | 103 ms | 2040 KB | Output is correct |
17 | Correct | 158 ms | 2908 KB | Output is correct |
18 | Incorrect | 118 ms | 2424 KB | Output isn't correct |
19 | Incorrect | 144 ms | 2524 KB | Output isn't correct |
20 | Incorrect | 162 ms | 2936 KB | Output isn't correct |