40 lines
822 B
C++
40 lines
822 B
C++
|
#include "../../include/aoc.hpp"
|
||
|
#include <bits/stdc++.h>
|
||
|
using namespace std;
|
||
|
|
||
|
int main() {
|
||
|
ios::sync_with_stdio(0);
|
||
|
cin.tie(0);
|
||
|
|
||
|
unordered_set<string> all;
|
||
|
unordered_map<string, unordered_set<string>> m;
|
||
|
|
||
|
string line;
|
||
|
while (getline(cin, line)) {
|
||
|
string a = line.substr(0, 2);
|
||
|
string b = line.substr(3, 5);
|
||
|
all.insert(a);
|
||
|
all.insert(b);
|
||
|
m[a].insert(b);
|
||
|
m[b].insert(a);
|
||
|
}
|
||
|
|
||
|
int count = 0;
|
||
|
vector<string> vm;
|
||
|
vm.assign(all.begin(), all.end());
|
||
|
for (int i = 2; i < vm.size(); i++) {
|
||
|
for (int j = 1; j < i; j++) {
|
||
|
for (int k = 0; k < j; k++) {
|
||
|
const string &a = vm[i], &b = vm[j], &c = vm[k];
|
||
|
if (a[0] != 't' && b[0] != 't' && c[0] != 't') {
|
||
|
continue;
|
||
|
}
|
||
|
if (m[a].contains(b) && m[b].contains(c) && m[c].contains(a)) {
|
||
|
count++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
cout << count << '\n';
|
||
|
}
|