This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <array> | |
#include <map> | |
#include <set> | |
using Point = std::array<int, 2>; | |
inline Point operator+(const Point& p1, const Point& p2) { | |
return {{std::get<0>(p1) + std::get<0>(p2), std::get<1>(p1) + std::get<1>(p2)}}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// compile with -O3 -march=native -std=c++14 | |
#include <array> | |
#include <chrono> | |
#include <cstdint> | |
#include <cstdlib> | |
#include <iostream> | |
#include <map> | |
#include <regex> | |
#include <string> | |
#include <unordered_map> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <array> | |
#include <map> | |
#include <set> | |
// A point is just an array of two elements | |
using Point = std::array<int, 2>; | |
// We need to add two points to make a new point, so let's write operator+ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <chrono> | |
#include <iostream> | |
#include <string> | |
int main(int argc, char**) { | |
auto start = std::chrono::high_resolution_clock::now(); | |
uint LIM{argc > 1 ? 35651584U : 272U}; | |
std::string in; | |
in.reserve(LIM << 1); // big buffer | |
std::cin >> in; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BasedOnStyle: Mozilla | |
AlignAfterOpenBracket: Align | |
AlignEscapedNewlinesLeft: 'true' | |
AlignOperands: 'true' | |
AlignTrailingComments: 'true' | |
AllowAllParametersOfDeclarationOnNextLine: 'false' | |
AllowShortBlocksOnASingleLine: 'false' | |
AllowShortCaseLabelsOnASingleLine: 'false' | |
AllowShortFunctionsOnASingleLine: None | |
AllowShortIfStatementsOnASingleLine: 'false' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Expressive Pi | |
// ------------- | |
// | |
// Fluent C++ Blog Post: The Pi Day Challenge for Expressive Code | |
// http://www.fluentcpp.com/2017/03/02/the-pi-day-challenge-for-expressive-code-in-c/ | |
// | |
// Author: William Killian | |
// Email: [email protected] | |
// Github: http://www.github.com/willkill07 | |
// Website: https://www.eecis.udel.edu/~wkillian |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// use C++11 to compile | |
#include <array> | |
#include <limits> | |
#include <numeric> | |
#include <type_traits> | |
#ifdef _OPENMP | |
#include <omp.h> | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
template <typename T, typename Tag> | |
struct StrongType { | |
T value; | |
explicit StrongType(T v) : value(v) {} | |
StrongType() = default; | |
StrongType(StrongType const &) = default; | |
StrongType(StrongType &&) = default; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace impl { | |
template <template <class ...> class L, class = L<>, class = L<>, class ...> | |
struct concat_ { | |
using type = L<>; | |
}; | |
template <template <class ...> class L, | |
template <class ...> class L1, class ... T1> | |
struct concat_<L, L1<T1...>> { | |
using type = L<T1...>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <utility> | |
namespace detail { | |
template <typename Seq, std::size_t Idx, typename T, T Val, T DefaultVal> | |
struct make_list_with_index_value; | |
template <std::size_t Idx, typename T, T Val, T DefaultVal, std::size_t ... Ids> | |
struct make_list_with_index_value<std::index_sequence<Ids...>, Idx, T, Val, DefaultVal> { | |
using type = std::integer_sequence<T, ((Idx == Ids) ? Val : DefaultVal)...>; | |
}; |