# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
598918 | almothana05 | Cards (LMIO19_korteles) | C++14 | 804 ms | 26116 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |