Submission #716373

#TimeUsernameProblemLanguageResultExecution timeMemory
716373Charizard2021Cards (LMIO19_korteles)C++17
100 / 100
413 ms29456 KiB
#include<bits/stdc++.h> using namespace std; inline int hashing(string s) { return int(s[0] - 'A') * 26 * 26 * 26 + int(s[1] - 'A') * 26 * 26 + int(s[2] - 'A') * 26 + int(s[3] - 'A'); } int main() { int n; cin >> n; vector<vector<int> > left(676), right(676), up(676), down(676); vector<string> s(n); vector<bool> st(676 * 676); for (int i = 0; i < n; ++i) { string sa, sb; cin >> sa >> sb; s[i] = sa + sb; int cu = (s[i][0] - 'A') * 26 + (s[i][1] - 'A'); int cd = (s[i][2] - 'A') * 26 + (s[i][3] - 'A'); int cl = (s[i][0] - 'A') * 26 + (s[i][2] - 'A'); int cr = (s[i][1] - 'A') * 26 + (s[i][3] - 'A'); up[cu].push_back(cd); down[cd].push_back(cu); left[cl].push_back(cr); right[cr].push_back(cl); st[hashing(s[i])] = true; } int ans = 0; for (int i = 0; i < 676; ++i) { vector<int> a = left[i]; vector<int> b = right[i]; ans += a.size() * b.size(); vector<bool> arr1(676); vector<bool> arr2(676); for(int j = 0; j < a.size(); j++){ arr1[a[j]] = true; } for(int j = 0; j < b.size(); j++){ arr2[b[j]] = true; } if(arr2[i] && arr1[i]){ --ans; } } for (int i = 0; i < 676; ++i) { vector<int> a = up[i]; vector<int> b = down[i]; ans += a.size() * b.size(); vector<bool> arr1(676); vector<bool> arr2(676); for(int j = 0; j < a.size(); j++){ arr1[a[j]] = true; } for(int j = 0; j < b.size(); j++){ arr2[b[j]] = true; } if(arr2[i] && arr1[i]){ --ans; } } int twos = 0, fours = 0; for (int i = 0; i < n; ++i) { string val1 = string(1, s[i][2]) + string(1, s[i][3]) + string(1, s[i][0]) + string(1, s[i][1]); string val2 = string(1, s[i][1]) + string(1, s[i][0]) + string(1, s[i][3]) + string(1, s[i][2]); if (s[i] != val1 && st[hashing(val1)]){ ++twos; } if (s[i] != val2 && st[hashing(val2)]){ ++twos; } if (s[i][1] == s[i][2]) { for (char c = 'A'; c <= 'Z'; ++c) { string opp3 = string(1, c) + string(1, s[i][0]) + string(1, s[i][0]) + string(1, s[i][1]); string opp4 = string(1, s[i][2]) + string(1, s[i][3]) + string(1, s[i][3]) + string(1, c); if (s[i] != opp3 && st[hashing(opp3)]) ++twos; if (s[i] != opp4 && st[hashing(opp4)]) ++twos; } } if (s[i][0] == s[i][3]) { for (char c = 'A'; c <= 'Z'; ++c) { string opp3 = string(1, s[i][1]) + string(1, c) + string(1, s[i][0]) + string(1, s[i][1]); string opp4 = string(1, s[i][2]) + string(1, s[i][3]) + string(1, c) + string(1, s[i][2]); if (s[i] != opp3 && st[hashing(opp3)]) ++twos; if (s[i] != opp4 && st[hashing(opp4)]) ++twos; } } if (s[i][0] == s[i][3] && s[i][1] == s[i][2]) { string opp5 = string(1, s[i][1]) + string(1, s[i][0]) + string(1, s[i][0]) + string(1, s[i][1]); if (s[i] != opp5 && st[hashing(opp5)]) ++fours; } } twos /= 2; fours /= 2; cout << ans - twos + fours * 3 << endl; return 0; }

Compilation message (stderr)

korteles.cpp: In function 'int main()':
korteles.cpp:33:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         for(int j = 0; j < a.size(); j++){
      |                        ~~^~~~~~~~~~
korteles.cpp:36:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |         for(int j = 0; j < b.size(); j++){
      |                        ~~^~~~~~~~~~
korteles.cpp:49:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |         for(int j = 0; j < a.size(); j++){
      |                        ~~^~~~~~~~~~
korteles.cpp:52:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |         for(int j = 0; j < b.size(); j++){
      |                        ~~^~~~~~~~~~
#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...