CCCPaste

Untitled

#include 

using namespace std;
int n,m;
int mat[100][100];
int dp[100][100];
pair path[100][100];
int rek(int i,int j)
{
    if(i==n-1  && j==n-1)
    {
        path[i][j] = make_pair(i, j);
        return mat[i][j];
    }
    if(dp[i][j]!=-1)
    {
        return dp[i][j];
    }
    int maks=-2e9;
    int desno = -2e9;
    int dole = -2e9;
    if(j+1 desno) {
        path[i][j] = make_pair(i + 1, j);
    }
    else {
        path[i][j] = make_pair(i, j + 1);
    }
    
    dp[i][j]=maks;
    return maks;
}
int main()
{
    cin>>n>>m;
    for(int i=0;i>mat[i][j];
        }
    }
    for(int i=0;i at = make_pair(0, 0); at != make_pair(n - 1, m - 1); at = make_pair(path[at.first][at.second].first, path[at.first][at.second].second)) {
        cout << at.first  + 1<< " " << at.second + 1<< endl;
    }
    cout << n << " " << m << endl;
    return 0;
}