This repository has been archived on 2021-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
sys_prog/checker/checker.cc

38 lines
675 B
C++
Raw Normal View History

2019-12-18 09:37:59 +00:00
// vim: set ts=2 sw=2 et tw=80:
#include <cassert>
#include <map>
class checker {
struct pos {
unsigned x;
unsigned y;
pos(unsigned x, unsigned y) : x(x), y(y) {};
};
unsigned c;
unsigned r;
std::map<pos, bool> map;
public:
checker(unsigned c, unsigned r) : c(c), r(r), map() {}
void visit(unsigned int x, unsigned int y);
bool visited(unsigned x, unsigned y);
};
void checker::visit(unsigned x, unsigned y) {
this->map[pos(] = true;
}
bool checker::visited(unsigned x, unsigned y) {
return this->map[x * this->c + y];
}
int main() {
checker a(10, 10);
a.visit(1, 1);
assert(a.visited(1,1));
assert(!a.visited(1,0));
}