#include #include #include using namespace std; struct pos { pos(int x, int y, const pos *next) : x(x), y(y), next(next) {} const int x; const int y; const pos *next; }; unordered_map old; int square(int n) { return n*n; } int main() { int v = 0; int m = 0; for (int d=0; d<=140; d++) { for (int x=0; x<=d; x++) { int y=d-x; cout << m++ << ' ' << v << endl; int w; if (old[v]) { w = numeric_limits::max(); const pos *walker=old[v]; do { int d=square(x-walker->x)+square(y-walker->y); if (w>d) { w=d; } walker=walker->next; } while (walker); } else { w=0; } old[v] = new pos(x,y,old[v]); v=w; } } return 0; }