You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
800 B
32 lines
800 B
#include <bitset>
|
|
#include "solutions.hpp"
|
|
|
|
using namespace std;
|
|
|
|
template <>
|
|
pair<string, string> solve<5>(istream& input) {
|
|
uint64_t max_seatid = 0;
|
|
size_t part2 = 0;
|
|
bitset<1024> taken_seats;
|
|
for (string line; getline(input, line); ) {
|
|
uint64_t seatid = 0;
|
|
for (auto c : line) {
|
|
seatid <<= 1;
|
|
switch (c) {
|
|
case 'B':
|
|
case 'R':
|
|
seatid++;
|
|
}
|
|
}
|
|
max_seatid = max(seatid, max_seatid);
|
|
taken_seats.set(seatid);
|
|
}
|
|
for (size_t i = 1; i < taken_seats.size(); ++i) {
|
|
if (taken_seats[i-1] && taken_seats[i+1] && !taken_seats[i]) {
|
|
part2 = i;
|
|
break;
|
|
}
|
|
}
|
|
|
|
return pair(to_string(max_seatid), to_string(part2));
|
|
}
|