#include <iostream>
#include <string>
#include <functional>
class Ticker {
private:
std::function<void()> callback;
public:
void setCallback(std::function<void()> cb) {
callback = cb;
}
void tick() {
if (callback) callback();
}
};
int main() {
Ticker sys_tick;
sys_tick.setCallback([count=0]() mutable{
count++;
std::cout<<"Count: "<<count<<std::endl;
});
// TODO: Define a lambda that maintains state.
// Hint: Use [count = 0]() mutable { ... }
// The lambda should increment count and print:
// "Count: " << count << std::endl;
// sys_tick.setCallback(...);
int N;
if (!(std::cin >> N)) return 0;
for (int i = 0; i < N; ++i) {
std::string cmd;
std::cin >> cmd;
if (cmd == "TICK") {
sys_tick.tick();
}
}
return 0;
}