diff options
author | kaiwu <kaiwu2004@gmail.com> | 2023-01-10 23:07:55 +0800 |
---|---|---|
committer | kaiwu <kaiwu2004@gmail.com> | 2023-01-10 23:07:55 +0800 |
commit | ce11d231adbcf7c36f24c9669dc007d4e2cba784 (patch) | |
tree | f1bcbe79a8e4cccf74ef73a282a265db0bbc1d4b /src/2022/day16/aoc.cpp | |
parent | 4cb1155522ee3a4bc59583ff1858b2670d4cc356 (diff) | |
download | advent-of-code-ce11d231adbcf7c36f24c9669dc007d4e2cba784.tar.gz advent-of-code-ce11d231adbcf7c36f24c9669dc007d4e2cba784.zip |
2022 day16 part2
Diffstat (limited to 'src/2022/day16/aoc.cpp')
-rw-r--r-- | src/2022/day16/aoc.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/2022/day16/aoc.cpp b/src/2022/day16/aoc.cpp index 5ef909f..fad148c 100644 --- a/src/2022/day16/aoc.cpp +++ b/src/2022/day16/aoc.cpp @@ -100,6 +100,20 @@ void flow(int m, valve* v, std::map<valve*, int> opened, int os, int total, int* } } +void flow(int m, valve* v1, valve* v2, std::map<valve*, int> opened, int os, int total, int* max) { + update_total(&total, opened, m); + if (m == 0) { + if (*max < total) { + *max = total; + } + } else { + if (os >= maxopened) { + flow(m - 1, v1, v2, opened, os, total, max); + } else { + } + } +} + std::pair<int, int> day16(line_view file) { per_line(file, [](line_view lv) { valve* v = new valve{lv}; @@ -139,6 +153,10 @@ std::pair<int, int> day16(line_view file) { std::map<valve*, int> opened; flow(30, get("AA"), opened, 0, 0, &m1); + opened.clear(); + int m2{INT32_MIN}; + flow(26, get("AA"), get("AA"), opened, 0, 0, &m2); + return {m1, 0}; } |