Submission

Status:
(PPPPPPPPPP)

Score: 100

User: admin

Problemset: Path Finding

Language: cpp

Time: 0.002 second

Submitted On: 2025-03-12 15:32:11

// YoruoniVamp - VTUBE

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ld long double
#define ull unsigned ll
#define cint const int
#define cf const float

cint mxA = 1e6+5, MOD = 1e9+7, INF = 0x3f3f3f3f;
cint d4x[4] = {0, 1, 0, -1}, d4y[4] = {1, 0, -1, 0};
cint d8x[8] = {0, 1, 1, 1, 0, -1, -1, -1}, d8y[8] = {1, 1, 0, -1, -1, -1, 0, 1};

void solve(){
    int n, m; cin >> n >> m;
    m--;
    char grid[n][n], now = 'A';
    memset(grid,'_',sizeof(grid));
    int x, y, tx, ty; cin >> y >> x;
    if(x<0||y<0||x>=n||y>=n){
        cout << "Out of range";
        return;
    }
    grid[y][x] = now;
    ty = y, tx = x;
    while(m--){
        cin >> y >> x;
        if(x<0||y<0||x>=n||y>=n){
            cout << "Out of range";
            return;
        }
        if(x>tx){
            for(int i = tx+1; i <= x; i++){
                grid[ty][i] = '>';
            }
        }else{
            for(int i = tx-1; i >= x; i--){
                grid[ty][i] = '<';
            }
        }int ttx = tx;
        tx = x;
        if(y>ty){//
            for(int i = (x==ttx?ty+1:ty); i <= y; i++){
                grid[i][tx] = 'v';
            }
        }else{
            for(int i = (x==ttx?ty-1:ty); i >= y; i--){
                grid[i][tx] = '^';
            }
        }ty = y;
        now++;
        grid[y][x] = now;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++) cout << grid[i][j];
        cout << endl;
    }
    return;
}

int main(){
    cin.tie(nullptr)->sync_with_stdio(0);cout.tie(0);
    // freopen("", "r", stdin);
    // freopen("", "w", stdout);
    int t = 1;
    // cin >> t;
    while(t--) solve();
    return 0;
}