aboutsummaryrefslogtreecommitdiff
path: root/2024/23/day23a.cpp
blob: 048a72446d6cee1892f19b5b011641f11437b38b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <algorithm>
#include <cstdint>
#include <iostream>
#include <map>
#include <queue>
#include <ranges>
#include <set>
#include <sstream>
#include <string>
#include <string_view>
#include <vector>
using namespace std;

set<int> computers;
bool m[26*26][26*26];

int index(char a, char b) { return (int)(a-'a') + 26*(int)(b-'a'); }
bool t(int i) { return i % 26 == 't' - 'a'; }

int main() {
	string line;
	while (getline(cin, line)) {
		int i = index(line[0], line[1]);
		int j = index(line[3], line[4]);
		computers.insert(i);
		computers.insert(j);
		m[i][j] = m[j][i] = true;
	}

	vector cv(computers.begin(), computers.end());
	int tot = 0;
	for (unsigned i = 0; i < cv.size(); i++)
		for (unsigned j = i+1; j < cv.size(); j++)
			for (unsigned k = j+1; k < cv.size(); k++)
				tot += m[cv[i]][cv[j]] && m[cv[j]][cv[k]] && m[cv[k]][cv[i]] &&
				       (t(cv[i]) || t(cv[j]) || t(cv[k]));

	cout << tot << endl;
	return 0;
}

Generated with cgit - Back to sebastiano.tronto.net