Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PLL;

LL n,d1,d2;
vector<PLL> vec;

bool sq(LL x)
{
    LL y=sqrt(x);
    if(y*y==x)return 1;
    return 0;
}

bool mark[605][605];

vector<PLL>ans;

void solve(int p,int q)
{
    memset(mark,0,sizeof mark);
    while(ans.size()>0)ans.pop_back();
    ans.clear();
    int cnt=0,x,y;
    for(int i=q;i<2*n;i++)
    {
        int j=0;
        if(i==q)j=p;
        for(;j<2*n;j++)
        {
            if(!mark[i][j])
            {
                ans.push_back(make_pair(i,j));
                cnt++;
                if(cnt==n*n)return;
                for(int k=0;k<vec.size();k++)
                {
                    x=i+vec[k].first;
                    y=j+vec[k].second;
                    if(x>=2*n || y>=2*n || y<0)continue;
                    mark[x][y]=1;
                }
            }
        }
    }
}

int main()
{
    cin>>n>>d1>>d2;
    for(LL i=0;i<=d1;i++)
    {
        if(sq(i) && sq(d1-i))vec.push_back(make_pair(sqrt(i),sqrt(d1-i)));
    }
    for(LL i=0;i<=d2;i++)
    {
        if(sq(i) && sq(d2-i))vec.push_back(make_pair(sqrt(i),sqrt(d2-i)));
    }
    int sz=vec.size();
    for(int i=0;i<sz;i++)vec.push_back(make_pair(vec[i].first,-vec[i].second));
    if(!vec.empty())
    {
        sort(vec.begin(),vec.end());
        vec.erase(unique(vec.begin(),vec.end()),vec.end());
    }
    for(int j=0;j<2*n;j++)
    {for(int i=0;i<min(20,2*n);i++)
    {
        solve(i,j);
        if(ans.size()==n*n)
        {
            for(int j=0;j<ans.size();j++)cout<<ans[j].first<<" "<<ans[j].second<<"\n";
            return 0;
        }

    }
    }


    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:68:23: error: no matching function for call to 'min(int, LL)'
   68 |     {for(int i=0;i<min(20,2*n);i++)
      |                    ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:68:23: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'LL' {aka 'long long int'})
   68 |     {for(int i=0;i<min(20,2*n);i++)
      |                    ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:68:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   68 |     {for(int i=0;i<min(20,2*n);i++)
      |                    ~~~^~~~~~~~