結果

問題 No.232 めぐるはめぐる (2)
ユーザー pekempeypekempey
提出日時 2015-06-26 23:00:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,019 bytes
コンパイル時間 2,108 ms
コンパイル使用メモリ 149,904 KB
実行使用メモリ 9,320 KB
最終ジャッジ日時 2023-09-22 01:27:59
合計ジャッジ時間 5,534 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
7,668 KB
testcase_01 AC 138 ms
7,812 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 10 ms
7,472 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 6 ms
5,244 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,384 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
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 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:21: warning: ‘dx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             int dy, dx;
                     ^~
main.cpp:34:17: warning: ‘dy’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             int ny = y + dy;
                 ^~

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrep2(i, a, b) for (int i = (a) - 1; i >= (b); i--)
#define all(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

int main() {
    int T, A, B;
    cin >> T >> A >> B;

    int x = 0, y = 0;

    vector<string> ans;

    rep (i, T) {
        if (i < T - 1) {
            int dy, dx;
            if (x < A && y < B) {
                dy = 1;
                dx = 1;
            } else if (x < A) {
                dy = 0;
                dx = 1;
            } else if (y < B) {
                dy = 1;
                dx = 0;
            }

            int ny = y + dy;
            int nx = x + dx;

            if (ny == A && nx == B) {
                if (y < B) {
                    if (x < A) dx = 1, dy = 0;
                    if (x == A) dx = -1, dy = 0;
                } else {
                    if (y < B) dy = 1, dx = 0;
                    if (y == B) dy = -1, dx = 0;
                }

                ny = y + dy;
                nx = x + dx;
            }

            string s;

            if (dy > 0) s += "^";
            if (dy < 0) s += "v";
            if (dx > 0) s += ">";
            if (dx < 0) s += "<";
            ans.push_back(s);

            y = ny;
            x = nx;
        } else {
            int dx = A - x;
            int dy = B - y;

            if (abs(dx) > 1 || abs(dy > 1)) {
                cout << "NO" << endl;
            } else {
                string s;

                cout << "YES" << endl;

                if (dy > 0) s += "^";
                if (dy < 0) s += "v";
                if (dx > 0) s += ">";
                if (dx < 0) s += "<";
                ans.push_back(s);

                for (string e : ans) {
                    cout << e << endl;
                }
            }
        }
    }
}
0