Submission

Status:
PPPPPPPPPP

Score: 100

User: Dormon

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

Language: cpp

Time: 0.003 second

Submitted On: 2024-11-17 13:59:35

#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

#define debug(...) Debug(#__VA_ARGS__, __VA_ARGS__)
using namespace std;

template<typename T>
typename std::enable_if<std::is_integral<T>::value>::type
Debug(const char* name, T value) {
    std::cout << name << " : " << value << '\n';
}

template<typename T, typename... Args>
typename std::enable_if<std::is_integral<T>::value>::type
Debug(const char* names, T value, Args... args) {
    const char* comma = strchr(names, ',');
    std::cout.write(names, comma - names) << " : " << value << " | ";
    Debug(comma + 1, args...);
}

void solve(){
    string s; cin >> s;
    vector<vector<char>> grid(52, vector<char>(52, '.'));
    grid[0][0] = 'a';


    int ni = 0, nj = 0, nn = 0, mm = 0;
    char k = 'b';
    for (int i = 1;i < s.size();i++){
        if (s[i] == 'D') ni++;
        else if (s[i] == 'R') nj++;
        else if (s[i] == 'L') nj--;
        else ni--;
        grid[ni][nj] = k++;
        if (k > 'z') 
            k = 'A';
        nn = max(nn, ni), mm = max(mm, nj);
    }

    for (int i = 0;i <= nn;i++){
        for (int j = 0;j <= mm;j++){
            cout << grid[i][j];
        }
        cout << '\n';
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int q = 1; 
    //cin >> q;
    while (q--){
        solve();
    }
}