結果

問題 No.232 めぐるはめぐる (2)
ユーザー pekempeypekempey
提出日時 2015-06-26 23:24:04
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,103 bytes
コンパイル時間 2,183 ms
コンパイル使用メモリ 149,972 KB
実行使用メモリ 8,504 KB
最終ジャッジ日時 2023-09-22 01:39:58
合計ジャッジ時間 3,503 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 136 ms
8,504 KB
testcase_01 AC 137 ms
7,520 KB
testcase_02 AC 132 ms
7,532 KB
testcase_03 AC 139 ms
7,912 KB
testcase_04 AC 8 ms
7,632 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 98 ms
7,680 KB
testcase_09 AC 5 ms
5,172 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 3 ms
4,380 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,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 2 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:41:21: warning: ‘dx’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             int dy, dx;
                     ^~
main.cpp:53: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;

string get(int dx, int dy) {
    string s;

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

    return s;
}

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

    int x = 0, y = 0;

    vector<string> ans;

    if (T == 1 && A == 0 && y == 0) {
        cout << "NO" << endl;
        return 0;
    }

    rep (i, T) {
        if (i == 0 && x == A && y == B) {
            ans.push_back(get(-1, -1));
            x = -1; y = -1;
        } else 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 (nx == A && ny == 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;
            }

            ans.push_back(get(dx, dy));

            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;
                ans.push_back(get(dx, dy));

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