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>
using namespace std;
map<string,int> mg,md,ml,mp;
set<string> se;
long long w,n;
string s;
char pg,pd,lg,ld;
bool czy_pozioma_os_symetrii(string karta){
// string karta = ""s + pg+lg+pd+ld;
return (karta[0] == karta[2] && karta[1]==karta[3]);
}
bool czy_pionowa_os_symetrii(string karta){
// string karta = ""s + pg+lg+pd+ld;
return (karta[0] == karta[1] && karta[2]==karta[3]);
}
bool symetria_osiowa(string karta){
// string karta = ""s + pg+lg+pd+ld;
return karta[0] == karta[3] && karta[1]==karta[2];
}
string lusterko_pionowo(string karta){
return ""s + karta[1]+karta[0]+karta[3]+karta[2];
}
string lusterko_poziomo(string karta){
// string karta = ""s + pg+lg+pd+ld;
return ""s + karta[2]+karta[3]+karta[0]+karta[1];
}
string odwroc(string s){
for(int i = 0;i < s.size()/2;i++)
swap(s[i],s[s.size()-i-1]);
return s;
}
int main(){
iostream::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int t = 0;t < n;t++){
cin >> lg >> pg >> ld >> pd;
string karta = ""s + pg+lg+pd+ld;
mg[""s + lg + pg]++;
md[""s + ld + pd]++;
ml[""s + lg + ld]++;
mp[""s + pg + pd]++;
if(czy_pozioma_os_symetrii(karta)) w--;
if(czy_pionowa_os_symetrii(karta)) w--;
if(symetria_osiowa(karta)){
if(se.count(lusterko_pionowo(karta))) w-=3;
} else {
if(se.count(lusterko_pionowo(karta))) w--;
if(se.count(lusterko_poziomo(karta))) w--;
}
se.insert(karta);
//cout << "wczesniej : " << w << "\n";
}
//cout << "g\n";
for(auto e : md){
s=e.first;
w+=e.second*mg[odwroc(s)];
//cout << w << " : " << e.first << " : " << e.second << " : " << odwroc(s) << " : " << mg[odwroc(s)] << "\n";
}
//cout << "p\n";
for(auto e : mp){
s=e.first;
w+=e.second*ml[odwroc(s)];
//cout << w << " : " << e.first << " : " << e.second << " : " << odwroc(s) << " : " << ml[odwroc(s)] << "\n";
}
//cout << "odp: ";
cout << w;
return 0;
}
Compilation message (stderr)
korteles.cpp: In function 'std::string odwroc(std::string)':
korteles.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | for(int i = 0;i < s.size()/2;i++)
| ~~^~~~~~~~~~~~
# | 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... |