제출 #1138889

#제출 시각아이디문제언어결과실행 시간메모리
1138889RaduMCards (LMIO19_korteles)C++20
100 / 100
901 ms110364 KiB
#pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #include <bits/stdc++.h> using namespace std; using ll = long long; vector < unordered_map <int, int> > mp(16); int c[16][676 * 676]; string s[2]; int h[4]; int main() { int n,i; ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; ll rez = 0; for(i = 1; i <= n; i++){ for(int e = 0; e < 2; e++){ cin.get(); cin >> s[e]; } h[0] = (s[0][0] - 65) * 26 + (s[0][1] - 65); h[2] = (s[1][0] - 65) * 26 + (s[1][1] - 65); h[1] = (s[0][0] - 65) * 26 + (s[1][0] - 65); h[3] = (s[0][1] - 65) * 26 + (s[1][1] - 65); for(int e = 1; e < 16; e++){ int temp = 0, nrb = __builtin_popcount(e); for(int j = 0; j < 4; j++){ if((1 << j) & e) temp = temp * 676 + h[j ^ 2]; } if(nrb <= 2){ if(nrb & 1) rez += c[e][temp]; else rez -= c[e][temp]; } else{ auto it = mp[e].find(temp); if(it != mp[e].end()){ if(nrb & 1) rez += it->second; else rez -= it->second; } } } for(int e = 1; e < 16; e++){ int temp = 0, nrb = __builtin_popcount(e); for(int j = 0; j < 4; j++){ if((1 << j) & e) temp = temp * 676 + h[j]; } if(nrb <= 2) c[e][temp]++; else mp[e][temp]++; } } cout << rez; return 0; }
#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...