Submission #598918

#TimeUsernameProblemLanguageResultExecution timeMemory
598918almothana05Cards (LMIO19_korteles)C++14
100 / 100
804 ms26116 KiB
#include<bits/stdc++.h> #define mod 1000000007 using namespace std; unordered_map<int , int>links , rechts , ob , un ; unordered_map<int , int>karte, linkob , obrech , rechun , untlink ; vector<int>pow26; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); long long menge , numm , nummer , len, erg = 0 ; string s, t; for(int i = 1 ; i <= 456976 ; i *= 26){ pow26.push_back(i); } // cout << pow26.size() << "\n"; cin >> menge; for(int i = 0 ; i < menge ; i++){ cin >> s; cin >> t; for(int j = 0 ; j < t.size() ; j++){ s += t[j]; } numm = 0; numm += pow26[1] * (s[0] - 'A' ); numm += pow26[3] * (s[2] - 'A' ); erg += rechts[numm]; numm = 0; numm += pow26[0] * (s[1] - 'A' ); numm += pow26[2] * (s[3] - 'A' ); erg += links[numm]; numm = 0; numm += pow26[2] * (s[0] - 'A' ); numm += pow26[3] * (s[1] - 'A' ); erg += un[numm]; numm = 0; numm += pow26[0] * (s[2] - 'A' ); numm += pow26[1] * (s[3] - 'A' ); erg += ob[numm]; if(s[0] == s[3] && s[1] == s[2]){ numm = 0; numm += pow26[0] * (s[1] - 'A' ); numm += pow26[1] * (s[0] - 'A' ); numm += pow26[2] * (s[3] - 'A' ); numm += pow26[3] * (s[2] - 'A' ); if(karte[numm] > 0){ erg += 3; } } ///////////////////////////////////////////////////// numm = 0; numm += pow26[0] * (s[1] - 'A' ); numm += pow26[1] * (s[0] - 'A' ); numm += pow26[2] * (s[3] - 'A' ); numm += pow26[3] * (s[2] - 'A' ); erg -= karte[numm]; ///////////////////////////////++++/////////////////////////////////////////////////////////////////////////////////////// numm = 0; numm += pow26[0] * (s[2] - 'A' ); numm += pow26[1] * (s[3] - 'A'); numm += pow26[2] * (s[0] - 'A' ); numm += pow26[3] * (s[1] - 'A'); erg -= karte[numm]; ////////////////////////////////////////////////////// numm = 0; numm += pow26[0] * (s[3] - 'A' ); numm += pow26[1] * (s[1] - 'A' ); numm += pow26[2] * (s[2] - 'A' ); numm += pow26[3] * (s[3] - 'A' ); erg -= linkob[numm]; // cout << erg << "\n"; numm = 0; numm += pow26[0] * (s[2] - 'A' ); numm += pow26[1] * (s[3] - 'A' ); numm += pow26[2] * (s[0] - 'A' ); numm += pow26[3] * (s[2] - 'A' ); erg -= obrech[numm]; numm = 0; numm += pow26[0] * (s[0] - 'A' ); numm += pow26[1] * (s[2] - 'A' ); numm += pow26[2] * (s[1] - 'A' ); numm += pow26[3] * (s[0] - 'A' ); erg -= rechun[numm]; numm = 0; numm += pow26[0] * (s[1] - 'A' ); numm += pow26[1] * (s[0] - 'A' ); numm += pow26[2] * (s[3] - 'A' ); numm += pow26[3] * (s[1] - 'A' ); erg -= untlink[numm]; ////////////////////////////////////////////////////// upd numm = 0; numm += pow26[0] * (s[0] - 'A' ); numm += pow26[1] * (s[1] - 'A' ); numm += pow26[2] * (s[2] - 'A' ); numm += pow26[3] * (s[3] - 'A' ); karte[numm]++; numm = 0; numm += pow26[0] * (s[0] - 'A' ); numm += pow26[2] * (s[2] - 'A' ); links[numm]++; numm = 0; numm += pow26[1] * (s[1] - 'A' ); numm += pow26[3] * (s[3] - 'A' ); rechts[numm]++; numm = 0; numm += pow26[0] * (s[0] - 'A' ); numm += pow26[1] * (s[1] - 'A' ); ob[numm]++; numm = 0; numm += pow26[2] * (s[2] - 'A' ); numm += pow26[3] * (s[3] - 'A' ); un[numm]++; //////////////////////////////////////////////////////up3 numm = 0; numm += pow26[0] * (s[2] - 'A' ); numm += pow26[1] * (s[0] - 'A' ); numm += pow26[2] * (s[0] - 'A' ); numm += pow26[3] * (s[1] - 'A' ); linkob[numm]++; numm = 0; numm += pow26[0] * (s[0] - 'A' ); numm += pow26[1] * (s[1] - 'A' ); numm += pow26[2] * (s[1] - 'A' ); numm += pow26[3] * (s[3] - 'A' ); obrech[numm]++; numm = 0; numm += pow26[0] * (s[1] - 'A' ); numm += pow26[1] * (s[3] - 'A' ); numm += pow26[2] * (s[3] - 'A' ); numm += pow26[3] * (s[2] - 'A' ); rechun[numm]++; numm = 0; numm += pow26[0] * (s[3] - 'A' ); numm += pow26[1] * (s[2] - 'A' ); numm += pow26[2] * (s[2] - 'A' ); numm += pow26[3] * (s[0] - 'A' ); untlink[numm]++; // cout << erg << "\n"; } cout << erg<< "\n"; }

Compilation message (stderr)

korteles.cpp: In function 'int main()':
korteles.cpp:20:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |       for(int j = 0 ; j < t.size() ; j++){
      |                       ~~^~~~~~~~~~
korteles.cpp:10:29: warning: unused variable 'nummer' [-Wunused-variable]
   10 |    long long menge , numm , nummer , len, erg = 0 ;
      |                             ^~~~~~
korteles.cpp:10:38: warning: unused variable 'len' [-Wunused-variable]
   10 |    long long menge , numm , nummer , len, erg = 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...