Submission

Status:
PPPPPPPPPP

Score: 100

User: njoop

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

Language: cpp

Time: 0.002 second

Submitted On: 2024-11-30 23:05:53

#include <bits/stdc++.h>

using namespace std;

int mx=1, my=1, cx=1, cy=1, cnt=1;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
char arr[100][100];

int move(char c) {
    if(c == 'U') return 2;
    if(c == 'R') return 1;
    if(c == 'D') return 0;
    else return 3;
}

int main() {
    string s;
    cin >> s;
    for(int i=1; i<=100; i++) {
        for(int j=1; j<=100; j++) {
            arr[i][j] = '.';
        }
    }
    arr[1][1] = 'a';
    for(int i=1; i<s.size(); i++) {
        cx += dx[move(s[i])];
        cy += dy[move(s[i])];
        mx = max(mx, cx);
        my = max(my, cy);
        cnt++;
        if(cnt <= 26) {
            arr[cx][cy] = 'a'+cnt-1;
        } else {
            arr[cx][cy] = 'A'+cnt-27;
        }
    }
    for(int i=1; i<=mx; i++) {
        for(int j=1; j<=my; j++) {
            cout << arr[i][j];
        }
        cout << "\n";
    }
    return 0;
}