Language: C++

// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int board[610][610], N;
void coor_insert(vector<int> &X, vector<int> &Y, int D) {
    for(int r=-D; r<=D; r++) {
        if(r*r > D) continue;
        int rest = D - r*r;
        int tmp = sqrt(rest), c = -INF;
        for(int k=tmp-1; k<=tmp+1; k++) {
            if(k*k == rest) {
                c = k;
                break;
            }
        }

        if(c == -INF) continue;

        // r, c が決定した
        X.push_back(r);
        Y.push_back(c);

        if(c != 0) {
            X.push_back(r);
            Y.push_back(-c);
        }
    }
}

void paint_board(vector<int> &X, vector<int> &Y, int r, int c, int &amount) {
    int M = X.size();

    for(int i=0; i<M; i++) {
        int nr = r + X[i], nc = c + Y[i];
        if(nr < 0 || nr >= 2*N || nc < 0 || nc >= 2*N) continue;
        if(board[nr][nc] == 0) amount--;
        board[nr][nc] = 1;
    }
}

struct Rand {
public:
    Rand() = default;
    Rand(std::mt19937::result_type seed) : eng(seed) {}
    int NextInt(int lb, int ub) {
        return std::uniform_int_distribution<int>{lb, ub}(eng);
    }
    ll NextLong(ll lb, ll ub) {
        return std::uniform_int_distribution<ll>{lb, ub}(eng);
    }
    double NextDouble(double lb, double ub) {
        return std::uniform_real_distribution<double>{lb, ub}(eng);
    }
private:
    std::mt19937 eng{std::random_device{}()};
};
Rand rnd(114514);

bool solve(vector<int> &X, vector<int> &Y) {
    vector<int> ans_X, ans_Y;
    vector<int> cand_X, cand_Y, ok(4*N*N, 1);
    for(int i=0; i<2*N; i++) {
        for(int j=0; j<2*N; j++) {
            cand_X.push_back(i);
            cand_Y.push_back(j);
        }
    }

    fill(board[0], board[610], 0);
    int rest = N*N, amount = 4*N*N;
    while(rest--) {
        int idx = rnd.NextInt(0, 4*N*N-1);
        if(!ok[idx]) {rest++; continue;}

        int i = cand_X[idx], j = cand_Y[idx];
        if(board[i][j] == 1) {rest++; continue;}

        // printf("valid: %lld, %lld\n", i, j);
        ok[idx] = 0;
        ans_X.push_back(i);
        ans_Y.push_back(j);
        paint_board(X, Y, i, j, amount);

        if(amount == 0) break;
    }

    // printf("size = %zu, amount = %lld\n", ans_X.size(), amount);

    if(ans_X.size() != N*N) return false;
    for(int i=0; i<N*N; i++) {
        printf("%lld %lld\n", ans_X[i], ans_Y[i]);
    }
    return true;
}

signed main() {
    int D1, D2; cin >> N >> D1 >> D2;
    vector<int> X, Y;
    coor_insert(X, Y, D1);
    coor_insert(X, Y, D2);

    while(!solve(X, Y));
    return 0;
}

Compiler output:
a.cc:87:15: error: 'std::mt19937' has not been declared
   87 |     Rand(std::mt19937::result_type seed) : eng(seed) {}
      |               ^~~~~~~
a.cc:87:35: error: expected ')' before 'seed'
   87 |     Rand(std::mt19937::result_type seed) : eng(seed) {}
      |         ~                         ^~~~~
      |                                   )
a.cc:98:10: error: 'mt19937' in namespace 'std' does not name a type
   98 |     std::mt19937 eng{std::random_device{}()};
      |          ^~~~~~~
a.cc: In member function 'long long int Rand::NextInt(long long int, long long int)':
a.cc:89:59: error: 'eng' was not declared in this scope
   89 |         return std::uniform_int_distribution<int>{lb, ub}(eng);
      |                                                           ^~~
a.cc: In member function 'll Rand::NextLong(ll, ll)':
a.cc:92:58: error: 'eng' was not declared in this scope
   92 |         return std::uniform_int_distribution<ll>{lb, ub}(eng);
      |                                                          ^~~
a.cc: In member function 'double Rand::NextDouble(double, double)':
a.cc:95:21: error: 'uniform_real_distribution' is not a member of 'std'; did you mean 'uniform_int_distribution'?
   95 |         return std::uniform_real_distribution<double>{lb, ub}(eng);
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~
      |                     uniform_int_distribution
a.cc:95:47: error: expected primary-expression before 'double'
   95 |         return std::uniform_real_distribution<double>{lb, ub}(eng);
      |                                               ^~~~~~
a.cc:95:47: error: expected ';' before 'double'
a.cc:95:53: error: expected unqualified-id before '>' token
   95 |         return std::uniform_real_distribution<double>{lb, ub}(eng);
      |                                                     ^
a.cc:95:63: error: 'eng' was not declared in this scope
   95 |         return std::uniform_real_distribution<double>{lb, ub}(eng);
      |                                                               ^~~
a.cc: At global scope:
a.cc:100:16: error: no matching function for call to 'Rand::Rand(int)'
  100 | Rand rnd(114514);
      |                ^
a.cc:86:5: note: candidate: 'constexpr Rand::Rand()'
   86 |     Rand() = default;
      |     ^~~~
a.cc:86:5: note:   candidate expects 0 arguments, 1 provided
a.cc:84:8: note: candidate: 'constexpr Rand::Rand(const Rand&)'
   84 | struct Rand {
      |        ^~~~
a.cc:84:8: note:   no known conversion for argument 1 from 'int' to 'const Rand&'
a.cc:84:8: note: candidate: 'constexpr Rand::Rand(Rand&&)'
a.cc:84:8: note:   no known conversion for argument 1 from 'int' to 'Rand&&'