Language: C++

#include <bits/stdc++.h>
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0' && ch<='9'){
		x=x*10+ch-'0';ch=getchar();
	}
	return x*f;
}
const int N=600;
int n,d1,d2,col[2][N*N];
std::vector< std::pair<int,int> > v[2];
inline int id(const int &x,const int &y) {
    return x*N+y;
}
inline bool check(const int &x) {
    return 0<=x&&x<n*2;
}
void dfs(const int &x,const int &t) {
    const int i=x/N,j=x%N;
    for (auto &d:v[t]) {
        const int nx=i+d.first,ny=j+d.second;
        if (!check(nx)||!check(ny)) continue;
        const int y=id(i+d.first,j+d.second);
        if (!col[t][y]) {
            col[t][y]=col[t][x]==1?2:1;
            dfs(y,t);
        }
    }
}
int main() {
    n=read(),d1=read(),d2=read();
    for (register int i=0;i<=d1;i++) {
        const int j=sqrt(d1-i*i);
        if (i*i+j*j!=d1) continue;
        v[0].emplace_back(std::make_pair(i,j));
        v[0].emplace_back(std::make_pair(-i,j));
        v[0].emplace_back(std::make_pair(i,-j));
        v[0].emplace_back(std::make_pair(-i,-j));
    }
    for (register int i=0;i<=d2;i++) {
        const int j=sqrt(d2-i*i);
        if (i*i+j*j!=d2) continue;
        v[1].emplace_back(std::make_pair(i,j));
        v[1].emplace_back(std::make_pair(-i,j));
        v[1].emplace_back(std::make_pair(i,-j));
        v[1].emplace_back(std::make_pair(-i,-j));
    }
    for (register int i=0;i<n*2;i++) {
        for (register int j=0;j<n*2;j++) {
            if (!col[0][id(i,j)]) {
                col[0][id(i,j)]=1;
                dfs(id(i,j),0);
            }
            if (!col[1][id(i,j)]) {
                col[1][id(i,j)]=1;
                dfs(id(i,j),1);
            }
        }
    }
    for (register int i=0,cnt=0;i<n*2;i++) {
        for (register int j=0;j<n*2;j++) {
            if (col[0][id(i,j)]==1&&col[1][id(i,j)]==1) {
                printf("%d %d\n",i,j);
                if (++cnt==n*n) return 0;
            }
        }
    }


Compiler output:
a.cc: In function 'int main()':
a.cc:37:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   37 |     for (register int i=0;i<=d1;i++) {
      |                       ^
a.cc:45:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   45 |     for (register int i=0;i<=d2;i++) {
      |                       ^
a.cc:53:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   53 |     for (register int i=0;i<n*2;i++) {
      |                       ^
a.cc:54:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   54 |         for (register int j=0;j<n*2;j++) {
      |                           ^
a.cc:65:23: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   65 |     for (register int i=0,cnt=0;i<n*2;i++) {
      |                       ^
a.cc:65:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   65 |     for (register int i=0,cnt=0;i<n*2;i++) {
      |                           ^~~
a.cc:66:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   66 |         for (register int j=0;j<n*2;j++) {
      |                           ^
a.cc:72:6: error: expected '}' at end of input
   72 |     }
      |      ^
a.cc:35:12: note: to match this '{'
   35 | int main() {
      |            ^