Submission
Status:
[-SSSSSSSSS]
Subtask/Task Score:
{0/100}
Score: 0
User: kavin8888
Problemset: Path Finding
Language: cpp
Time: 0.002 second
Submitted On: 2025-10-13 20:47:55
#include<bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(nullptr)->sync_with_stdio(false);
int n,q;
cin>>n>>q;
bool gern=false;
vector<pair<int,int>> pos(q);
for(int i=0;i<q;i++)
{
cin>>pos[i].first>>pos[i].second;
if(pos[i].first<0 || pos[i].second>=n || pos[i].second<0 || pos[i].second>=n)
{
gern=true;
}
}
if(gern)
{
cout<<"Out of range\n";
return 0;
}
string tmp="";
for(int i=0;i<n;i++)
{
tmp+="_";
}
vector<string> out(n,tmp);
for(int i=1;i<q;i++)
{
if(pos[i].second>pos[i-1].second)
{
for(int j=pos[i-1].second+1;j<pos[i].second;j++)
{
out[pos[i-1].first][j]='>';
}
}
else if(pos[i].second<pos[i-1].second)
{
for(int j=pos[i-1].second-1;j>pos[i].second;j--)
{
out[pos[i-1].first][j]='<';
}
}
if(pos[i].first>pos[i-1].first)
{
for(int j=pos[i-1].first;j<pos[i].first;j++)
{
out[j][pos[i].second]='v';
}
}
else if(pos[i].first<pos[i-1].first)
{
for(int j=pos[i-1].first;j>pos[i].first;j--)
{
out[j][pos[i].second]='^';
}
}
out[pos[i].first][pos[i].second]='A'+i;
}
for(int i=0;i<out.size();i++)
{
cout<<out[i]<<'\n';
}
}