Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: anonymous

Problemset: นักเดินทาง

Language: cpp

Time: 0.003 second

Submitted On: 2026-11-04 21:49:49

#include <bits/stdc++.h>
using namespace std;

const int A = 200;

char ch = 'a';
vector<vector<char>> grid(A, vector<char> (A, '.'));

int32_t main(){
    cin.tie(0)->sync_with_stdio(0);

    string type; cin >> type;
    int max_x = 100, min_x = 100;
    int min_y = 100, max_y = 100;
    int x = 100,y = 100;

    bool f = true;
    for(char& c : type){
        if(f){
            f = false;
            continue;
        }

        if(ch > 'z') ch = 'A';
        grid[x][y] = ch; ch++;

        if(c == 'D') x++;
        if(c == 'U') x--;
        if(c == 'L') y--;
        if(c == 'R') y++;
        max_x = max(max_x, x);
        min_x = min(min_x, x);
        max_y = max(max_y, y);
        min_y = min(min_y, y);
    }

    grid[x][y] = ch;
    for(int i = min_x;i<=max_x;i++){
        for(int j=min_y;j<=max_y;j++){
            cout << grid[i][j];
        }
        cout << '\n';
    }
}