# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
135428 | 2019-07-24T05:27:45 Z | 윤교준(#3250) | PIN (CEOI10_pin) | C++14 | 674 ms | 7672 KB |
#include <bits/stdc++.h> #define eb emplace_back #define sz(V) ((int)(V).size()) #define befv(V) ((V)[sz(V)-2]) #define allv(V) ((V).begin()),((V).end()) #define sorv(V) sort(allv(V)) #define INF (0x3f3f3f3f) #define INFLL (0x3f3f3f3f3f3f3f3fll) using namespace std; typedef long long ll; typedef pair<int, int> pii; int B[36][36][36][36]; int A[50005][4]; ll Ans; int N, K; ll solve2() { ll ret = 0; for(int i = 0; i < N; i++) { int a = A[i][0], b = A[i][1], c = A[i][2], d = A[i][3]; for(int j = 0; j < 36; j++) if(j != a) { for(int k = 0; k < 36; k++) { if(k != b) ret += B[j][k][c][d]; if(k != c) ret += B[j][b][k][d]; if(k != d) ret += B[j][b][c][k]; } } for(int j = 0; j < 36; j++) if(j != b) { for(int k = 0; k < 36; k++) { if(k != c) ret += B[a][j][k][d]; if(k != d) ret += B[a][j][c][k]; } } for(int j = 0; j < 36; j++) if(j != c) { for(int k = 0; k < 36; k++) if(k != d) ret += B[a][b][j][k]; } } return ret >> 1; } ll solve1() { int ret = 0; for(int i = 0; i < N; i++) { int a = A[i][0], b = A[i][1], c = A[i][2], d = A[i][3]; for(int j = 0; j < 36; j++) { if(j != a) ret += B[j][b][c][d]; if(j != b) ret += B[a][j][c][d]; if(j != c) ret += B[a][b][j][d]; if(j != d) ret += B[a][b][c][j]; } } return ret >> 1; } int main() { scanf("%d%d", &N, &K); for(int i = 0; i < N; i++) { char str[5]; scanf(" %s", str); for(int j = 0; j < 4; j++) { if('0' <= str[j] && str[j] <= '9') A[i][j] = str[j] & 15; else A[i][j] = str[j] - 'a' + 10; } B[A[i][0]][A[i][1]][A[i][2]][A[i][3]]++; } if(1 == K) Ans = solve1(); else if(2 == K) Ans = solve2(); cout << Ans << endl; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1656 KB | Output is correct |
2 | Correct | 17 ms | 1656 KB | Output is correct |
3 | Incorrect | 3 ms | 1656 KB | Output isn't correct |
4 | Correct | 10 ms | 1912 KB | Output is correct |
5 | Correct | 11 ms | 2040 KB | Output is correct |
6 | Correct | 204 ms | 2140 KB | Output is correct |
7 | Correct | 167 ms | 2040 KB | Output is correct |
8 | Correct | 12 ms | 2040 KB | Output is correct |
9 | Correct | 18 ms | 2424 KB | Output is correct |
10 | Correct | 408 ms | 2552 KB | Output is correct |
11 | Correct | 216 ms | 2168 KB | Output is correct |
12 | Incorrect | 9 ms | 2424 KB | Output isn't correct |
13 | Incorrect | 6 ms | 2040 KB | Output isn't correct |
14 | Incorrect | 6 ms | 2040 KB | Output isn't correct |
15 | Incorrect | 8 ms | 2424 KB | Output isn't correct |
16 | Correct | 23 ms | 7388 KB | Output is correct |
17 | Correct | 674 ms | 7672 KB | Output is correct |
18 | Incorrect | 13 ms | 7544 KB | Output isn't correct |
19 | Incorrect | 14 ms | 7544 KB | Output isn't correct |
20 | Incorrect | 16 ms | 7672 KB | Output isn't correct |