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> | |
using namespace std; | |
static ssize_t *memory = nullptr; | |
size_t lcs(const string &s1, const std::string &s2, size_t i1, size_t i2) { | |
if (!memory) { | |
size_t size = (s1.size() + 1) * (s2.size() + 1); |
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
class Defer { | |
public: | |
explicit Defer(std::function<void()> func) : func_(func) {} | |
~Defer() { func_(); } | |
private: | |
Defer(const Defer &) = delete; | |
Defer& operator=(const Defer &) = delete; | |
std::function<void()> func_; | |
}; |