Submission

Status:

[-SSSSSSSSS]

Subtask/Task Score:

{0/100}

Score: 0

User: ZanTy

Problemset: Path Finding

Language: cpp

Time: 0.004 second

Submitted On: 2026-10-09 12:51:38

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, q;
    if (!(cin >> n >> q)) return 0;
    vector<int> x(q), y(q);
    vector<vector<char>> arr(n, vector<char>(n, '_'));

    bool cancel = false;
    for (int i = 0; i < q; i++) {
        cin >> x[i] >> y[i];
        if (x[i] < 0 || x[i] >= n || y[i] < 0 || y[i] >= n) {
            cancel = true;
        } else {
            arr[x[i]][y[i]] = (char)('A' + i);
        }
    }

    if (cancel) {
        cout << "Out of range\n";
        return 0;
    }
    for (int i = 0; i < q - 1; i++) {
        int x1 = x[i], y1 = y[i];
        int x2 = x[i + 1], y2 = y[i + 1];
        if (y2 > y1) {
            for (int j = y1 + 1; j < y2; j++) {
                if (arr[x1][j] == '_') arr[x1][j] = '>';
            }
        } else if (y1 > y2) {
            for (int j = y1 - 1; j > y2; j--) {
                if (arr[x1][j] == '_') arr[x1][j] = '<';
            }
        }
        if (x2 > x1) {
            for (int i_idx = x1 + 1; i_idx < x2; i_idx++) {
                if (arr[i_idx][y2] == '_') arr[i_idx][y2] = 'v';
            }
        } else if (x1 > x2) {
            for (int i_idx = x1 - 1; i_idx > x2; i_idx--) {
                if (arr[i_idx][y2] == '_') arr[i_idx][y2] = '^';
            }
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cout << arr[i][j];
        }
        cout << '\n';
    }

    return 0;
}