Submission

Status:

[PPPPPPPPPP]

Subtask/Task Score:

{100/100}

Score: 100

User: detectives_conan

Problemset: Path Finding

Language: cpp

Time: 0.002 second

Submitted On: 2026-07-04 11:27:14

#include <bits/stdc++.h>

using namespace std;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int n; cin >> n;
    vector<vector<char>> res(n, vector<char>(n, '_'));
    int q; cin >> q;
    q--;
    int px, py; cin >> px >> py;
    char a = 'A';
    if(px >= n || py >= n || px < 0 || py < 0) return cout << "Out of range\n", 0;
    else{
        res[px][py] = a;
        a++;
    }
    while(q--){
        int x, y; cin >> x >> y;
        if(x >= n || y >= n || x < 0 || y < 0) return cout << "Out of range\n", 0;
        res[x][y] = a;
        a++;
        if(y > py){
            for(int i = py + 1; i < y; ++i) res[px][i] = '>';
        }
        else if(y < py){
            for(int i = y + 1; i < py; ++i) res[px][i] = '<';
        }
        if(x > px){
            int st = (y == py ? px + 1 : px);
            for(int i = st; i < x; ++i) res[i][y] = 'v';
        }
        else if(x < px){
            int en = (y == py ? px - 1 : px);
            for(int i = x + 1; i <= en; ++i) res[i][y] = '^';
        }
        px = x, py = y;
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j) cout << res[i][j];
        cout << '\n';
    }
}