Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll MOD = 998244353;
const int N = 305;

int mat[2*N][2*N];

vector<pair<int, int>> dist;
int n, d1, d2;

int square[2 * N * 2 * N];

int sq(int x){
	if(x < 0) return -1;
	if(x >= 2*N*2*N) return -1;
	return square[x];
}

int main(){

	memset(square, -1, sizeof square);

	for(int x = 0; x * x < 2*N*2*N; x++) square[x*x] = x;

	scanf("%d %d %d", &n, &d1, &d2);

	{
		set<pair<int, int>> s;
		for(int dx = 0; dx < 2*n; dx++){
			int dy = sq(d1 - dx*dx);
			if(dy == -1) continue;
			s.emplace(dx, dy);
			s.emplace(-dx, dy);
			s.emplace(dx, -dy);
			s.emplace(-dx, -dy);
		}
		for(int dx = 0; dx < 2*n; dx++){
			int dy = sq(d2 - dx*dx);
			if(dy == -1) continue;
			s.emplace(dx, dy);
			s.emplace(-dx, dy);
			s.emplace(dx, -dy);
			s.emplace(-dx, -dy);
		}
		for(auto x : s) dist.push_back(x);
	}

	vector<pair<int, int>> pos;
	for(int i = 0; i < 2*n; i++) for(int j = 0; j < 2*n; j++){
		pos.emplace(i, j);	
	}

	srand(time(0));
	random_shuffle(pos.begin(), pos.end());
	random_shuffle(pos.begin(), pos.end());
	random_shuffle(pos.begin(), pos.end());
	random_shuffle(pos.begin(), pos.end());
	random_shuffle(pos.begin(), pos.end());
	random_shuffle(pos.begin(), pos.end());
	random_shuffle(pos.begin(), pos.end());

	vector<pair<int, int>> ans;
	int i, j;
	for(auto ww : pos){
		tie(i, j) = ww;
		if(mat[i][j]) continue;
		mat[i][j] = 1;
		ans.emplace_back(i, j);
		if((int)ans.size() == n*n) break;
		int x, y;
		for(auto w : dist){
			tie(x, y) = w;
			x += i, y += j;
			if(x < 0 || x >= 2*n) continue;
			if(y < 0 || y >= 2*n) continue;
			mat[x][y] = 1;
		}
	}

	assert((int)ans.size() == n*n);
	for(auto w : ans) printf("%d %d\n", w.first, w.second);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:28: error: no matching function for call to 'std::vector<std::pair<int, int> >::emplace(int&, int&)'
   53 |                 pos.emplace(i, j);
      |                 ~~~~~~~~~~~^~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1348:9: note: candidate: 'template<class ... _Args> std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::emplace(const_iterator, _Args&& ...) [with _Args = {_Args ...}; _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >]'
 1348 |         emplace(const_iterator __position, _Args&&... __args)
      |         ^~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1348:9: note:   template argument deduction/substitution failed:
a.cc:53:29: note:   cannot convert 'i' (type 'int') to type 'std::vector<std::pair<int, int> >::const_iterator'
   53 |                 pos.emplace(i, j);
      |                             ^
a.cc:57:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   57 |         random_shuffle(pos.begin(), pos.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_algo.h:4492:5: note: declared here
 4492 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
a.cc:58:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   58 |         random_shuffle(pos.begin(), pos.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4492:5: note: declared here
 4492 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
a.cc:59:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   59 |         random_shuffle(pos.begin(), pos.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4492:5: note: declared here
 4492 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
a.cc:60:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   60 |         random_shuffle(pos.begin(), pos.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4492:5: note: declared here
 4492 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
a.cc:61:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   61 |         random_shuffle(pos.begin(), pos.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4492:5: note: declared here
 4492 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
a.cc:62:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   62 |         random_shuffle(pos.begin(), pos.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4492:5: note: declared here
 4492 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~
a.cc:63:23: warning: 'void std::random_shuffle(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<pair<int, int>*, vector<pair<int, int> > >]' is deprecated: use 'std::shuffle' instead [-Wdeprecated-declarations]
   63 |         random_shuffle(pos.begin(), pos.end());
      |         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4492:5: note: declared here
 4492 |     random_shuffle(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~~~~~~~~~~~