Language: C++

#include<iostream>
#include<vector>
#include<set>
using namespace std;
#define r(a) for(int a=0;a<10;a++)

struct pain{short int x,y,s,t;};
vector<pain>vec;
set<vector<short int> >se;

short int n;
vector<vector<short int> >c(10,vector<short int>(10,0));

short int s(short int i,short int j){ if(!i||!j||i==9||j==9)return 0;return min(c[i][j],min(c[i-1][j],min(c[i+1][j],min(c[i][j+1],c[i][j-1])))); return 0; }
short int m(short int i,short int j){ return min(s(i,j),min(c[i-1][j-1],min(c[i-1][j+1],min(c[i+1][j-1],c[i+1][j+1])))); }
short int l(short int i,short int j){ return min(m(i,j),min(c[i-2][j],min(c[i+2][j],min(c[i][j-2],c[i][j+2])))); }

void ds(short int i,short int j,short int ma){ c[i][j]-=ma;c[i-1][j]-=ma;c[i+1][j]-=ma;c[i][j+1]-=ma;c[i][j-1]-=ma; }
void dm(short int i,short int j,short int ma){ c[i-1][j-1]-=ma;c[i-1][j+1]-=ma;c[i+1][j-1]-=ma;c[i+1][j+1]-=ma; }
void dl(short int i,short int j,short int ma){ c[i-2][j]-=ma;c[i+2][j]-=ma;c[i][j-2]-=ma;c[i][j+2]-=ma; }

void is(short int i,short int j,short int ma){ c[i][j]+=ma;c[i-1][j]+=ma;c[i+1][j]+=ma;c[i][j+1]+=ma;c[i][j-1]+=ma; }
void im(short int i,short int j,short int ma){ c[i-1][j-1]+=ma;c[i-1][j+1]+=ma;c[i+1][j-1]+=ma;c[i+1][j+1]+=ma; }
void il(short int i,short int j,short int ma){ c[i-2][j]+=ma;c[i+2][j]+=ma;c[i][j-2]+=ma;c[i][j+2]+=ma; }

bool eval(){
    int suc=1;
    r(a)r(b)
    if(c[a][b])suc=0;
    if(suc){
        for(int k=0;k<vec.size();k++)
            while(vec[k].t--)cout<<vec[k].y<<" "<<vec[k].x<<" "<<vec[k].s<<endl;
        return 1;
    }
    return 0;
}
bool eva(short int i,short int j){
    int suc=1;
    for(int a=0;a<i-2;a++)for(int b=0;b<j-2;b++)
        if(c[a][b])suc=0;
    return suc;
}
vector<short int> tr(vector<vector<short int> >vec){
    vector<short int>v;
    for(int i=0;i<10;i++)
        for(int j=0;j<10;j++)
            v.push_back(c[i][j]);
    return v;
}
bool dfs(int i,int j){
    if(i>1&&i<8&&j>1&&j<8){
        if(l(i,j)){
            
            pain tp;
            tp.x=i;tp.y=j;
            tp.t=0;
            tp.s=3;
            vec.push_back(tp);
            short int m1=l(i,j);
            dl(i,j,m1);dm(i,j,m1);ds(i,j,m1);
            vec[vec.size()-1].t=m1;
            if(!eva(i,j))goto n1;
            if(se.find(tr(c))!=se.end())goto n1;
            
            if(eval())return 1;
            r(a)r(b)
                if(s(a,b)&&dfs(a,b))
                    return 1;
            se.insert(tr(c));
        n1:
            il(i,j,m1);im(i,j,m1);is(i,j,m1);
            vec.pop_back();
        }
    }
    if(i>0&&i<9&&j>0&&j<9){
        if(m(i,j)){
            
            pain tp;
            tp.x=i;tp.y=j;
            tp.t=0;
            tp.s=2;
            vec.push_back(tp);
            short int m1=m(i,j);
            dm(i,j,m1);ds(i,j,m1);
            vec[vec.size()-1].t=m1;
            if(!eva(i,j))goto n2;
            if(se.find(tr(c))!=se.end())goto n2;
            if(eval())return 1;
            r(a)r(b)
            if(s(a,b)&&dfs(a,b))
                return 1;
            se.insert(tr(c));
        n2:
            im(i,j,m1);is(i,j,m1);
            vec.pop_back();
        }
        if(s(i,j)){
            
            tp.s=1;
            vec.push_back(tp);
            short int m1=s(i,j);
            ds(i,j,m1);
            tp.s=1;
            vec[vec.size()-1].t=m1;
            if(!eva(i,j))goto n3;
            if(se.find(tr(c))!=se.end())goto n3;
            if(eval())return 1;
            r(a)r(b)
            if(s(a,b)&&dfs(a,b))
                return 1;
            se.insert(tr(c));
        n3:
            is(i,j,m1);
            vec.pop_back();
        }
    }
    return 0;
}
int main(){
    cin>>n;
    r(i)r(j)
    cin>>c[i][j];
    r(i)r(j){
        if(s(i,j))dfs(i,j);
    }
}

Compiler output:
a.cc: In function 'bool dfs(int, int)':
a.cc:99:13: error: 'tp' was not declared in this scope; did you mean 'tr'?
   99 |             tp.s=1;
      |             ^~
      |             tr