제출 #587969

#제출 시각아이디문제언어결과실행 시간메모리
587969jmyszka2007Cards (LMIO19_korteles)C++17
100 / 100
171 ms5824 KiB
#include <bits/stdc++.h>
using namespace std;
int kon(char z) {
	return (int)z - 65;
}
int l[30][30];
int p[30][30];
int g[30][30];
int d[30][30];
int c[30][30][30][30];
int gp[30][30][30];
int dl[30][30][30];
int lg[30][30][30];
int pd[30][30][30];
int main() {
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++) {
		char tmp1, tmp2, tmp3, tmp4;
		cin >> tmp1 >> tmp2 >> tmp3 >> tmp4;
		int z1 = kon(tmp1);
		int z2 = kon(tmp2);
		int z3 = kon(tmp3);
		int z4 = kon(tmp4);
		ans += d[z1][z2];
		ans += l[z2][z4];
		ans += g[z3][z4];
		ans += p[z1][z3];
		if(z1 == z4) {
			ans -= dl[z2][z1][z2];
			ans -= gp[z3][z1][z3];
		}
		if(z2 == z3) {
			ans -= lg[z4][z2][z4];
			ans -= pd[z1][z2][z1];
		}
		if(z1 == z4 && z2 == z3) {
			ans += 3 * c[z2][z1][z1][z2];
		}
		ans -= c[z2][z1][z4][z3];
		ans -= c[z3][z4][z1][z2];
		g[z1][z2]++;
		p[z2][z4]++;
		d[z3][z4]++;
		l[z1][z3]++;
		lg[z3][z1][z2]++;
		gp[z1][z2][z4]++;
		pd[z2][z4][z3]++;
		dl[z4][z3][z1]++;
		c[z1][z2][z3][z4]++;
	}
	printf("%d\n", ans);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...