結果

問題 No.3723 Climb or Detour
コンテスト
ユーザー テナガザル
提出日時 2026-09-19 13:29:25
言語 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
結果
AC  
実行時間 3 ms / 2,000 ms
+ 966µs
コード長 704 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,121 ms
コンパイル使用メモリ 170,196 KB
実行使用メモリ 10,048 KB
最終ジャッジ日時 2026-09-19 13:31:57
合計ジャッジ時間 5,119 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int n, k;
  cin >> n >> k;
  int px[2], py[2];
  for (int i = 0; i < 2; ++i) cin >> px[i] >> py[i];
  for (int i = 0; i < 2; ++i)
  {
    --px[i];
    --py[i];
  }
  int tmpd = abs(px[0] - px[1]) + abs(py[0] - py[1]);
  if (k < tmpd || 2 * tmpd < k || tmpd % 2 != k % 2)
  {
    cout << "-1\n";
    return 0;
  }
  int sima = k - tmpd;
  vector<string> s(n, string(n, '.'));
  for (int i = 0; i < n; ++i)
  {
    for (int j = 0; j < n; ++j)
    {
      int tmp = abs(i - px[0]) + abs(j - py[0]);
      if (tmp % 2 && tmp < sima) s[i][j] = '#';
    }
  }
  for (int i = 0; i < n; ++i) cout << s[i] << endl;
}
0