Submission

Status:
[PPPPPPPPPP]

Score: 100

User: Namkhing

Problemset: Path Finding

Language: cpp

Time: 0.002 second

Submitted On: 2025-04-11 17:55:50

#include <bits/stdc++.h>
using namespace std;

using pii = pair<int, int>;

const int N = 1e5 + 10;

int main() {
    cin.tie(nullptr)->ios_base::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    vector<pii> v(q);
    for (auto &[x, y] : v) cin >> x >> y;
    for (auto &[x, y] : v) {
        if (x < 0 || x >= n || y < 0 || y >= n) {
            cout << "Out of range";
            return 0;
        }
    }
    vector<vector<char>> a(n, vector<char>(n, '_'));
    for (int i = 0; i < q - 1; i++) {
        auto [sx, sy] = v[i];
        auto [fx, fy] = v[i+1];
        while (sy < fy) a[sx][sy] = '>', sy++;
        while (sy > fy) a[sx][sy] = '<', sy--;
        while (sx < fx) a[sx][sy] = 'v', sx++;
        while (sx > fx) a[sx][sy] = '^', sx--;
        auto [x, y] = v[i];
        a[x][y] = 'A' + i;
    }
    auto [x, y] = v[q-1];
    a[x][y] = 'A' + q - 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) cout << a[i][j]; cout << "\n";
    }
}