結果

問題 No.232 めぐるはめぐる (2)
ユーザー furafura
提出日時 2023-09-12 19:45:30
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 1,244 bytes
コンパイル時間 3,440 ms
コンパイル使用メモリ 251,560 KB
実行使用メモリ 8,716 KB
最終ジャッジ日時 2023-09-12 19:45:36
合計ジャッジ時間 4,319 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
7,816 KB
testcase_01 AC 9 ms
8,060 KB
testcase_02 AC 11 ms
7,928 KB
testcase_03 AC 10 ms
8,716 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 8 ms
8,216 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

int main() {
    int t, a, b;
    scanf("%d%d%d", &t, &a, &b);

    if (max(a, b) > t) {
        puts("NO");
        return 0;
    }
    if (a == 0 && b == 0 && t == 1) {
        puts("NO");
        return 0;
    }

    vector<string> ops;
    int x = 0, y = 0;
    while (pair(x, y) != pair(b, a)) {
        string op;
        if (x < b) op += '>', x++;
        if (y < a) op += '^', y++;
        ops.emplace_back(op);
    }
    if (ops.empty()) {
        ops.emplace_back("^");
        ops.emplace_back("v");
    }

    while (ssize(ops) < t) {
        string op = ops.back();
        ops.pop_back();
        if (ssize(op) == 2) {
            ops.emplace_back(op.substr(0, 1));
            ops.emplace_back(op.substr(1));
        }
        else { // ssize(op) == 1
            if (op == "<" or op == ">") {
                ops.emplace_back(op + "^");
                ops.emplace_back("v");
            }
            else { // op == "^" or op == "v"
                ops.emplace_back(op + "<");
                ops.emplace_back(">");
            }
        }
    }

    puts("YES");
    for (const auto& op: ops) puts(op.c_str());

    return 0;
}
0