#pragma GCC optimize ("O3") #include "bits/stdc++.h" using namespace std; #define rep(i, b, e) for(int i = (b); i <= (e); i++) #define per(i, b, e) for(int i = (e); i >= (b); i--) #define FOR(i, b, e) rep(i, b, (e) - 1) #define SZ(x) int(x.size()) #define all(x) x.begin(), x.end() #define pb push_back #define mp make_pair #define st first #define nd second using ll = long long; using pii = pair; using vi = vector; auto &operator<<(auto &o, pair p) { return o << "(" << p.st << ", " << p.nd << ")"; } auto operator<<(auto &o, auto x)->decltype(end(x), o) { o << "{"; int i=0; for(auto e: x) o << ", " + 2*!i++ << e; return o << "}"; } #ifdef LOCAL #define deb(x...) cerr << "[" #x << "]: ", [](auto...$) { ((cerr << $ << "; "),...) << endl; }(x) #else #define deb(...) #endif const int N = 18 * 18; using B = bitset; B lans; int ans; void cliq(vector &eds, B P = ~B(), B X={}, B R={}) { if(!P.any()) { int res = R.count(); if(res > ans) { ans = res; lans = R; } return; } auto q = (P | X)._Find_first(); auto cands = P & ~eds[q]; if((int)(R.count() + cands.count()) <= ans) return; FOR(i, 0, SZ(eds)) if(cands[i]) { R[i] = 1; cliq(eds, P & eds[i], X & eds[i], R); R[i] = P[i] = 0; X[i] = 1; } } void solve() { int n; double r; cin >> n >> r; map ind; map rind; int nr = 0; int bound = ceil(r); rep(i, bound, n-bound) rep(j, bound, n-bound) { rind[nr] = {i, j}; ind[{i, j}] = nr++; } vector g(nr); set dists; rep(i, bound, n-bound) rep(j, bound, n-bound) rep(k, bound, n-bound) rep(l, bound, n-bound) { int dst = (i - k) * (i - k) + (j - l) * (j - l); if(dst >= 4 * r * r - 1e-3) g[ind[{i, j}]][ind[{k, l}]] = 1; dists.insert(dst); } deb(SZ(dists)); deb(dists); cliq(g); cout << ans << '\n'; FOR(i, 0, nr) if(lans[i]) cout << rind[i].st << ' ' << rind[i].nd << '\n'; } int main() { cin.tie(0)->sync_with_stdio(0); int tt = 1; // cin >> tt; FOR(te, 0, tt) solve(); return 0; }