結果

問題 No.2228 Creeping Ghost
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2023-02-24 22:26:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 2,073 ms
コンパイル使用メモリ 200,356 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-11 06:28:57
合計ジャッジ時間 3,185 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 1 ms
4,368 KB
testcase_04 AC 1 ms
4,368 KB
testcase_05 AC 14 ms
4,372 KB
testcase_06 AC 8 ms
4,372 KB
testcase_07 AC 15 ms
4,372 KB
testcase_08 AC 15 ms
4,372 KB
testcase_09 AC 8 ms
4,372 KB
testcase_10 AC 8 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const string key = "URDL";
string ans1 = "RLRD";
int ans2[] = {2, 0, 2, 1};
int main () {
    int N;
    cin >> N;
    if (N <= 4) {
        cout << ans1.substr(0, N) << endl;
        return 0;
    }
    cout << ans1;
    N -= 4;
    int a = N / 4, b = N % 4;
    for (int i = 0; i < a; i ++) {
        for (int j = 0; j < 4; j ++) {
            cout << key[(3 * i + ans2[j]) % 4];
        }
    }
    for (int j = 0; j < b; j ++) {
        cout << key[(a * 3 + ans2[j]) % 4];
    }
    cout << endl;
}
0