std::vector<unsignedlonglong> hash(MAXL + 1); for (int i = 0; i <= MAXL; i++) hash[i] = rand(); std::vector<unsignedlonglong> list(6); for (int i = 0; i < 6; i++) list[i] = rand();
std::unordered_map<unsignedlonglong, bool> vis; for (int i = 0; i < n; i++) { std::vector<int> a(12); for (int i = 0; i < 6; i++) { scanf("%d", &a[i]); a[i + 6] = a[i]; }
for (int j = 0; j < 6; j++) { unsignedlonglong res = 0; for (int k = 0; k < 6; k++) res += hash[a[j + k]] * list[k]; if (vis[res]) { puts("Twin snowflakes found."); return0; } elseif (j == 0) vis[res] = true; } for (int j = 0; j < 6; j++) { unsignedlonglong res = 0; for (int k = 0; k < 6; k++) res += hash[a[j + 5 - k]] * list[k]; if (vis[res]) { puts("Twin snowflakes found."); return0; } elseif (j == 0) vis[res] = true; } }