제출 #799557

#제출 시각아이디문제언어결과실행 시간메모리
799557vjudge1Cards (LMIO19_korteles)C++17
36 / 100
1095 ms30228 KiB
#include <iostream> #include <map> using namespace std; map<tuple<char, char, char, char>, long long int> m; struct DOM { char a, b, x, y; }; bool check(DOM aa, DOM bb) { if (aa.a == bb.x && aa.b == bb.y) return 1; if (aa.b == bb.a && aa.y == bb.x) return 1; if (aa.x == bb.a && aa.y == bb.b) return 1; if (aa.a == bb.b && aa.x == bb.y) return 1; return 0; } DOM a[100005]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n, res = 0; cin >> n; if (n <= 2500) { for (int i = 1; i <= n; i++) { cin >> a[i].a >> a[i].b >> a[i].x >> a[i].y; for (int j = 1; j < i; j++) { if (check(a[i], a[j])) { res++; } } } cout << res; return 0; } for (int i = 1; i <= n; i++) { char a, b, x, y; cin >> a >> b >> x >> y; char r = '?'; res += m[{r, r, a, b}] + m[{b, r, y, r}] + m[{r, a, r, x}] + m[{x, y, r, r}]; res -= m[{b, a, y, x}] + m[{x, y, a, b}]; if (y == a) res -= m[{x, y, r, x}]; if (y == a) res -= m[{b, r, a, b}]; if (x == b) res -= m[{b, y, y, r}]; if (x == b) res -= m[{r, a, a, x}]; if (b == x && a == y) { res += m[{b, a, y, x}] * 3; } m[{a, b, r, r}]++; m[{r, b, r, y}]++; m[{a, r, x, r}]++; m[{r, r, x, y}]++; m[{r, b, x, y}]++; m[{a, r, x, y}]++; m[{a, b, r, y}]++; m[{a, b, x, r}]++; m[{a, b, x, y}]++; } cout << res; }
#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...