Submission

Status:

[-SSSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: nate213121

Problemset: Path Finding

Language: cpp

Time: 0.002 second

Submitted On: 2026-09-05 16:36:20

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    int pointsNumber;
    cin >> pointsNumber;
    vector<vector<char>> grid(n, vector<char>(n));
    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            grid[i][j] = '_';
        }
    }
    vector<pair<int, int>> points;
    vector<char> alphabet = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
    for(int i = 0; i < pointsNumber; i++)
    {
        int row, column;
        cin >> row >> column;
        if(!(row >= 0 && row < n && column >= 0 && column < n))
        {
            cout << "Out of range";
            return 0;
        }
        points.push_back(make_pair(row, column));
    }
    int row = points[0].first;
    int column = points[0].second;
    grid[row][column] = alphabet[0];
    for(int i = 1; i < pointsNumber; i++)
    {
        int dR = points[i].first - row;
        int dC = points[i].second - column;
        int startR = row;
        int startC = column;
        grid[row][column] = alphabet[i - 1];
        //cout << dR << " " << dC << endl;
        if(dC > 0)
        {
            for(int x = 0; x < dC; x++)
            {
                //cout << "LOOP" << endl;
                grid[row][column] = '>';
                column++;
            }
        }
        else
        {
            for(int x = 0; x < -dC; x++)
            {
                //cout << "LOOP" << endl;
                grid[row][column] = '<';
                column--;
            }
        }
        if(dR > 0)
        {
            for(int x = 0; x < dR; x++)
            {
                //cout << "LOOP" << endl;
                grid[row][column] = 'v';
                row++;
            }
        }
        else
        {
            for(int x = 0; x < -dR; x++)
            {
                //cout << "LOOP" << endl;
                grid[row][column] = '^';
                row--;
            }
        }
        grid[row][column] = alphabet[i];
    }

    for(int i = 0; i < n; i++)
    {
        //cout << "OUTPUT LOOP" << endl;
        for(int j = 0; j < n; j++)
        {
            //cout << "OUTPUT LOOP" << endl;
            cout << grid[i][j];
        }
        cout << endl;
    }
    return 0;
}