Submission
Status:
[PxSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: Kidmaiok
Problemset: Path Finding
Language: cpp
Time: 0.002 second
Submitted On: 2026-10-13 11:53:26
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define syace << ' '
#define nl << endl
void up(int n, int x1, int y1, int x2, int y2, vector<vector<char>>& arr){
for(int i = y1; i > y2 ; i--){
arr[i][x2] = '^';
}
}
void down(int n, int x1, int y1, int x2, int y2, vector<vector<char>>& arr){
for(int i = y1; i < y2 ; i++){
arr[i][x2] = 'v';
}
}
void right(int n, int x1, int y1, int x2, int y2, vector<vector<char>>& arr){
for(int i = x1; i < x2; i++){
arr[y1][i] = '>';
}
}
void left(int n, int x1, int y1, int x2, int y2, vector<vector<char>>& arr){
for(int i = x1; i > x2 ; i--){
arr[y1][i] = '<';
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
int q;
cin >> q;
vector<vector<char>> arr(n, vector<char>(n));
vector<pair<int,int>> corr;
for (int r = 0; r < n; r++) {
for (int c = 0; c < n; c++) {
arr[r][c] = '_';
}
}
for(int i =0; i < q;i ++){
int x,y;
cin >> y >> x;
corr.push_back({y,x});
}
for(int i =0; i < q-1;i++){
if(corr[i].second > corr[i+1].second){
left(n, corr[i].second, corr[i].first, corr[i+1].second, corr[i+1].first, arr);
}
if(corr[i].second < corr[i+1].second){
right(n, corr[i].second, corr[i].first, corr[i+1].second, corr[i+1].first, arr);
}
if(corr[i].first < corr[i+1].first){
down(n, corr[i].second, corr[i].first, corr[i+1].second, corr[i+1].first, arr);
}
if(corr[i].first > corr[i+1].first){
up(n, corr[i].second, corr[i].first, corr[i+1].second, corr[i+1].first, arr);
}
arr[corr[i].first][corr[i].second] = char('A' + i);
arr[corr[i+1].first][corr[i+1].second] = char('A' + i + 1);
}
for (int r = 0; r < n; r++) {
for (int c = 0; c < n; c++) {
cout << arr[r][c];
}
cout << "\n";
}
}