Submission
Status:
[PPPPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: Some1258
Problemset: Path Finding
Language: cpp
Time: 0.004 second
Submitted On: 2026-07-27 09:40:07
#include<bits/stdc++.h>
using namespace std;
struct Point{
int r,c;
};
int main(){
int N,npoint;
cin>>N>>npoint;
vector<Point> point(npoint);
for(int i=0;i<npoint;i++){
cin>>point[i].r>>point[i].c;
if(point[i].r<0||point[i].r>=N||point[i].c<0||point[i].c>=N){
cout<<"Out of range";
return 0;
}
}
vector<string> mp(N,string(N,'_'));
if(npoint==0){
for(const string& row:mp){
cout<<row<<'\n';
}
return 0;
}
mp[point[0].r][point[0].c]='A';
for(int i=1;i<npoint;i++){
int r=point[i-1].r;
int c=point[i-1].c;
int targetr=point[i].r;
int targetc=point[i].c;
bool ia=false;
if(targetc!=c){
ia=true;
}
while(c<targetc){
c++;
if(c!=targetc||r!=targetr){
mp[r][c]='>';
}
}
while(c>targetc){
c--;
if(c!=targetc||r!=targetr){
mp[r][c]='<';
}
}
if(ia){
if(r<targetr){
mp[r][c]='v';
}else if(r>targetr){
mp[r][c]='^';
}
}
while(r<targetr){
r++;
if(r!=targetr){
mp[r][c]='v';
}
}
while(r>targetr){
r--;
if(r!=targetr){
mp[r][c]='^';
}
}
mp[targetr][targetc]=char('A'+i);
}
for(const string &row:mp){
cout<<row<<'\n';
}
}