結果

問題 No.3723 Climb or Detour
コンテスト
ユーザー てんぷら
提出日時 2026-09-19 13:31:18
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,674 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,972 ms
コンパイル使用メモリ 331,868 KB
実行使用メモリ 10,052 KB
最終ジャッジ日時 2026-09-19 13:32:40
合計ジャッジ時間 6,005 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 47 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
#ifdef TEMPURA
#else
#define debug(...) ((void)0)
#define msg(...) ((void)0)
#endif
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++)

using ll = long long;
using ull = unsigned long long;
using i128 = __int128_t;

template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
// #include <atcoder/modint>
// using mint = atcoder::modint998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    cin >> n >> k;
    int sr, sc, tr, tc;
    cin >> sr >> sc >> tr >> tc;
    --sr;
    --sc;
    --tr;
    --tc;
    int mi = abs(sr - tr) + abs(sc - tc);
    int ma = mi % 2 == 0 ? 2 * mi : 2 * mi - 1;
    if(k < mi || k > ma) {
        cout << -1 << endl;
        return 0;
    }
    rep(i, n) {
        rep(j, n) {
            if(i < min(sr, tr) || i > max(sr, tr) || j < min(sc, tc) || j > max(sc, tc)) {
                if((i + j) % 2 == (sr + sc) % 2) {
                    cout << '.';
                } else {
                    cout << '#';
                }
            } else {
                int d = abs(i - sr) + abs(j - sc);
                if(d % 2 == 0) {
                    cout << '.';
                } else if(d < k - mi) {
                    cout << '#';
                } else {
                    cout << '.';
                }
            }
        }
        cout << "\n";
    }
    return 0;
}
0