Submission #598832

#TimeUsernameProblemLanguageResultExecution timeMemory
598832shrimbCards (LMIO19_korteles)C++17
0 / 100
544 ms968 KiB
#include"bits/stdc++.h" using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template<class x> using ordered_set = tree<x, null_type,less_equal<x>, rb_tree_tag,tree_order_statistics_node_update>; #define int long long #define endl '\n' #define mod 1000000007 //\ #define mod 1686876991 int Hash (int a, int b) { return ((a * 1000000009 % mod * 1000000009 % mod) + b) % mod; } int Hashh (int a, int b) { return ((a * 1000000009 % mod) + b) % mod; } signed main () { cin.tie(0)->sync_with_stdio(0); int n; cin >> n; int ans = 0; unordered_map<int,int> mp[1<<4]; for (int i = 0 ; i < n ; i++) { char a, b, c, d; cin >> a >> b >> c >> d; int H[4] = {Hashh(a, b), Hashh(b, d), Hashh(c, d), Hashh(a, c)}; // U R D L vector<int> inc; int enc, ienc; int cnt = 0; int inv = 0; #define check(j,i,k) if (j & (1 << i)) { cnt++; enc = Hash(enc, H[i]); inv |= (1 << k);} for (int j = 1 ; j < (1 << 4) ; j++) { enc = ienc = 0; cnt = 0; inv = 0; check(j, 0, 2); check(j, 1, 3); check(j, 2, 0); check(j, 3, 1); for (int k = 0 ; k < 4 ; k++) { if (inv & (1 << k)) { ienc = Hash(ienc, H[(k + 2) % 4]); } } if (cnt & 1) ans += mp[inv][ienc]; else ans -= mp[inv][ienc]; // cerr << enc << endl; inc.push_back(enc); } for (int j = 1 ; j < (1 << 4) ; j++) mp[j][inc[j - 1]]++; } cout << ans << endl; }

Compilation message (stderr)

korteles.cpp:14:1: warning: multi-line comment [-Wcomment]
   14 | //\
      | ^
#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...