結果

問題 No.1714 Tag on Grid
ユーザー kazu107kazu107
提出日時 2021-10-22 22:28:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,123 bytes
コンパイル時間 1,272 ms
コンパイル使用メモリ 160,384 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 13:46:01
合計ジャッジ時間 2,193 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 WA -
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    int N, H, a, b, c, d; cin >> N >> H >> a >> b >> c >> d;
    bool key = false;
    if (a == c || b == d) {
        if (a == c && abs(b - d) == 1) {
            key = true;
        }
        else if (b == d && abs(a - c) == 1) {
            key = true;
        }
    }
    else if (abs(a - c) > abs(b - d)) {
        if (c == N || d == H || c == 1 || d == 1) {
            if (a > c) {
                a--;
            }
            else {
                b--;
            }
        }
        if (abs(a - c) == 1 && abs(b - d) == 1 && abs(a - b) == abs(c - d)) {
            key = true;
        }
    }
    else if (abs(a - c) <= abs(b - d)) {
        if (c == N || d == H || c == 1 || d == 1) {
            if (a > c) {
                a++;
            }
            else {
                b++;
            }
        }
        if (abs(a - c) == 1 && abs(b - d) == 1 && abs(a - b) == abs(c - d)) {
            key = true;
        }
    }
    if (key) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}
0