# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
501908 | vrohak | Cards (LMIO19_korteles) | C++14 | 83 ms | 9732 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5 * 1e5;
int a[27][27], b[27][27], c[27][27], d[27][27];
int ab[27][27][27], ad[27][27][27], bc[27][27][27], cd[27][27][27];
int abcd[27][27][27][27], ac[27][27][27], bd[27][27][27];
int x, y, z, w, n;
char cards[MAXN][4][4];
long long int sol = 0;
int main() {
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s", cards[i][0]);
scanf("%s", cards[i][1]);
}
for (int i = 0; i < n; i++) {
x = cards[i][0][0] - 'A';
y = cards[i][0][1] - 'A';
z = cards[i][1][0] - 'A';
w = cards[i][1][1] - 'A';
sol += a[w][z] + b[y][w] + c[x][y] + d[z][x];
sol -= abcd[w][z][x][y];
sol -= abcd[x][y][w][z];
if (y == z) {
sol -= ab[w][z][w];
sol -= cd[x][y][x];
}
if (x == w) {
sol -= ad[z][x][z];
sol -= bc[y][w][y];
}
if (y == z && w == x) sol += 3 * abcd[x][z][x][z];
a[y][x]++;
b[x][z]++;
c[z][w]++;
d[w][y]++;
ab[y][x][z]++;
ad[w][y][x]++;
bc[x][z][w]++;
cd[z][w][y]++;
abcd[y][x][z][w]++;
}
printf("%lld", sol);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |