제출 #502121

#제출 시각아이디문제언어결과실행 시간메모리
502121MardukCards (LMIO19_korteles)C++14
0 / 100
1069 ms64784 KiB
#include <bits/stdc++.h> using namespace std; #define X first #define Y second int n,sol; map<pair<string,int>,int> m; //prefix, up/down, id map<pair<string,string>,int> ob; map<pair<string,int>,int> mf; //prefix, up/down, id map<pair<string,string>,int> obf; map<pair<string,string>,int> isti; map<pair<char,char>,int> gay1, gay2, gay3, gay4, hm; pair<string,string> Flip(string x, string y){ return {string()+y[0]+x[0], string()+y[1]+x[1]}; } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 0;i<n;i++){ string a,b; cin >> a >> b; sol+=m[{a,1}]+m[{b,0}]-ob[{b,a}]; m[{a,0}]++; m[{b,1}]++; ob[{a,b}]++; pair<string,string> f = Flip(a,b); a = f.X; b = f.Y; sol+=mf[{a,1}]+mf[{b,0}]-obf[{b,a}]; mf[{a,0}]++; mf[{b,1}]++; obf[{a,b}]++; if(b[0]==a[1]){ sol-=gay4[{b[1],b[0]}]; sol-=gay1[{b[0],a[0]}]; gay1[{b[1],b[0]}]++; gay4[{b[0],a[0]}]++; if(a[0]==b[1]){ sol+=hm[{a[1],a[0]}]; hm[{a[0],a[1]}]++; } } if(a[0]==b[1]){ sol-=gay3[{a[1],a[0]}]; sol-=gay2[{a[0],b[0]}]; gay2[{a[1],a[0]}]++; gay3[{a[0],b[0]}]++; if(a[1]==b[0]){ sol+=hm[{a[1],a[0]}]; // hm[{a[0],a[1]}]++; } } // if(a[0]==a[1] && a[1] == b[0] && b[0] == b[1]){ // sol+=isti[{a,b}]; // isti[{a,b}]++; // } } cout << sol; }
#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...