AlpacaHack Logo

Challenges

Sign InSign Up

Type

Display

Difficulty

Rows:

DIFF.CHALLENGEAUTHORS

SOLVES

Loading challenges...

Rows:

Compile time flag checker

Daily AlpacaHackTopic: C++Released: Jul 12, 2026

48 solves
Rev
Hard

by

tan90909090

tan90909090

It can only be compiled with a correct flag.

Beginner Hint 1: C++ Features
  • chal.cpp uses various C++ language and library features.
    • The constexpr keyword indicates that variables or functions can be calculated at compile time.
    • The static_assert keyword checks if a condition is true, and shows an compile-error message if it does not; in chal.cpp, it is used as a flag checker.
    • The template keyword allows to abstract of type arguments and non-type arguments for functions and types.
    • The std::index_sequence type represents a sequence of size_t elements at the type level. std::make_index_sequence can be used to create a sequence starting from 0 with a specified number of elements.
    • The std::integer_sequence type represents a sequence of elements of a specified type at the type level; in chal.cpp, it is used as a sequence of std::uint8_t values.
    • Syntax like std::size_t... I or std::index_sequence<I...> within a template function represents a feature known as parameter packs. Within the function, syntax such as F(I)... is used to expand the parameter pack.
    • Syntax like [](std::size_t i) { return input_string_view[i]; } represents C++ lambda expression; in chal.cpp, it is used as the F type argument for my_make_sequence_t.
    • The decltype keyword retrieves the type of a value; in chal.cpp, it is used to recover the type from a std::integer_sequence value.
    • The std::is_same_v variable indicates whether two type arguments are identical; in chal.cpp, it is used as a flag checker.
  • You may want to investigate the details further if necessary.
Beginner Hint 2: Approach to Solving the Challenge
  • It is a good idea to start by understanding the calculations performed by the convolve_t type, the convolve_impl function, and the convolve_element function. In particular, the relationship between the sequence lengths of the two type arguments A and B for convolve_t and the sequence length of convolve_t itself is crucial.
  • Let's try examining the elements of the sequence generated by the odd_random_sequence_t type; using IDE features might make this easier.
compile-time-flag-checker.tar.gz

Please sign in to submit the flag.

descriptionsolveswriteups