Submission #598918

# Submission time Handle Problem Language Result Execution time Memory
598918 2022-07-19T07:37:30 Z almothana05 Cards (LMIO19_korteles) C++14
100 / 100
804 ms 26116 KB
#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

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 time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 220 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 5 ms 1492 KB Output is correct
9 Correct 5 ms 1108 KB Output is correct
10 Correct 4 ms 1108 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 804 ms 26060 KB Output is correct
2 Correct 794 ms 25892 KB Output is correct
3 Correct 802 ms 26036 KB Output is correct
4 Correct 780 ms 26116 KB Output is correct
5 Correct 783 ms 25876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 97 ms 10896 KB Output is correct
3 Correct 516 ms 24960 KB Output is correct
4 Correct 338 ms 18108 KB Output is correct
5 Correct 331 ms 18132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 220 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
4 Correct 5 ms 1492 KB Output is correct
5 Correct 5 ms 1108 KB Output is correct
6 Correct 4 ms 1108 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 340 KB Output is correct
11 Correct 0 ms 340 KB Output is correct
12 Correct 804 ms 26060 KB Output is correct
13 Correct 794 ms 25892 KB Output is correct
14 Correct 802 ms 26036 KB Output is correct
15 Correct 780 ms 26116 KB Output is correct
16 Correct 783 ms 25876 KB Output is correct
17 Correct 97 ms 10896 KB Output is correct
18 Correct 516 ms 24960 KB Output is correct
19 Correct 338 ms 18108 KB Output is correct
20 Correct 331 ms 18132 KB Output is correct
21 Correct 207 ms 16176 KB Output is correct
22 Correct 603 ms 25696 KB Output is correct
23 Correct 424 ms 25436 KB Output is correct
24 Correct 439 ms 25308 KB Output is correct