Submission

Status:

[PP-SSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: detectives_conan

Problemset: Path Finding

Language: cpp

Time: 0.002 second

Submitted On: 2026-07-04 11:20:26

#include <bits/stdc++.h>

using namespace std;

int main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int n; cin >> n;
    bool ck = false;
    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) ck = true;
    else{
        res[px][py] = a;
        a++;
    }
    while(q--){
        int x, y; cin >> x >> y;
        if(x >= n || y >= n || x < 0 || y < 0 || ck){
            ck = true;
            continue;
        }
        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){
            for(int i = px; i < x; ++i) res[i][y] = 'v';
        }
        else if(x < px){
            for(int i = x + 1; i <= px; ++i) res[i][y] = '^';
        }
        px = x, py = y;
    }
    if(ck){
        cout << "Out of range\n";
        return 0;
    }
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j) cout << res[i][j];
        cout << '\n';
    }
}