Submission
Status:
[PP-SSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: ChanakanStudy
Problemset: Path Finding
Language: cpp
Time: 0.004 second
Submitted On: 2026-10-11 14:20:18
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <numeric>
#include <iomanip>
using namespace std;
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
char a[n][n];
for(int i = 0;i<n;i++) {
for(int j = 0;j<n;j++) {
a[i][j] = '_';
}
}
int q;
cin >> q;
int count = 0;
while(q--) {
int x,y,rememberx,remembery;
cin >> x >> y;
if(x < 0 || x >= n || y < 0 || y >= n) {
cout << "Out of range";
return 0;
}
a[x][y] = char('A' + count);
if(count == 0) {
rememberx = x;
remembery = y;
}
else {
if(y > remembery-1) {
while(y != remembery) {
remembery += 1;
if(a[rememberx][remembery] != char('A' + count)) {
a[rememberx][remembery] = '>';
}
}
}
else if (y < remembery+1) {
while(y != remembery) {
remembery -= 1;
if(a[rememberx][remembery] != char('A' + count)) {
a[rememberx][remembery] = '<';
}
}
}
if(x > rememberx-1) {
while(x != rememberx) {
if(a[rememberx][remembery] != char('A' + count)) {
a[rememberx][remembery] = 'v';
}
rememberx += 1;
}
}
else if (x < rememberx+1) {
while(x != rememberx) {
if(a[rememberx][remembery] != char('A' + count)) {
a[rememberx][remembery] = '^';
}
rememberx -= 1;
}
}
rememberx = x;
remembery = y;
}
count++;
}
for(int i = 0;i<n;i++) {
for(int j = 0;j<n;j++) {
cout << a[i][j];
}
cout << '\n';
}
return 0;
}