Submission
Status:
[PP-SSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: ZanTy
Problemset: Path Finding
Language: cpp
Time: 0.002 second
Submitted On: 2026-10-08 14:04:21
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1005;
const int MAX_Q = 1005;
int targetx[MAX_Q];
int targety[MAX_Q];
int x[MAX_Q];
int y[MAX_Q];
char arr[MAX_N][MAX_N];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, q;
if (!(cin >> n >> q)) return 0;
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
arr[i][j] = '_';
}
}
int cancel = 0;
for (int i = 0; i < q; i++){
cin >> x[i] >> y[i];
if (0 > x[i] || x[i] >= n || 0 > y[i] || y[i] >= n){
cancel = 1;
} else {
arr[x[i]][y[i]] = (char)('A' + i);
}
if (i >= 1){
targetx[i-1] = x[i];
targety[i-1] = y[i];
}
}
if (cancel){
cout << "Out of range\n";
return 0;
}
for (int i = 0; i < q - 1; i++){
int state = 0;
int x1 = x[i];
int y1 = y[i];
int x2 = targetx[i];
int y2 = targety[i];
if (y2 > y1){
for (int j = 1; y1 + j != y2; j++){
char current = arr[x1][y1+j];
if (current >= 'A' && current <= 'Z') {
} else {
arr[x1][y1+j] = '>';
}
}
}
else if (y1 > y2){
for (int j = 1; y2 + j != y1; j++){
char current = arr[x1][y1-j];
if (current >= 'A' && current <= 'Z') {
// ??ʶҹբ?ҧ
} else {
arr[x1][y1-j] = '<';
}
}
}
if (y2 == y1){
state = 1;
}
if (x2 > x1){
for (int j = state; x1 + j != x2; j++){
char current = arr[x1+j][y2];
if (current >= 'A' && current <= 'Z') {
} else {
arr[x1+j][y2] = 'v';
}
}
}
else if (x2 < x1){
for (int j = state; x2 + j != x1; j++){
char current = arr[x1-j][y2];
if (current >= 'A' && current <= 'Z') {
} else {
arr[x1-j][y2] = '^';
}
}
}
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
cout << arr[i][j];
}
cout << '\n';
}
return 0;
}