結果

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

ソースコード

diff #
raw source code

// 対称性をなんとかする
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int main() {
	int n, K;
	int sy, sx, ty, tx;
	cin >> n >> K;
	cin >> sy >> sx >> ty >> tx;
	sy--; sx--; ty--; tx--;

	bool flip = false;
	if (sy > ty) {
		swap(sx, tx);
		swap(sy, ty);
	}
	if (sx > tx) {
		flip = true;
		swap(sx, tx);
	}

	int d = (ty - sy) + (tx - sx);
	int L = K - d;
	if (L < 0 || L > d || L % 2 != 0) { cout << -1 << endl; return 0; }

	int i, j;
	vector<vector<bool>> black(n, vector<bool>(n));
	rep(i, n) {
		rep(j, n) {
			int p = (i + j) - (sx + sy);
			if ((sx + sy) % 2 == (i + j) % 2 || (i + j) == (tx + ty)) {
				black[i][j] = false;
			}
			else if (0 <= p && p < L && p % 2 == 1) {
				black[i][j] = true;
			}
			else {
				black[i][j] = false;
			}
		}
	}

	if (flip) {
		rep(i, n) {
			int l = 0, r = n - 1;
			while (l < r) {
				swap(black[i][l], black[i][r]);
				l++; r--;
			}	
		}
	}

	rep(i, n) {
		rep(j, n) {
			if (black[i][j]) cout << "#";
			else cout << ".";
		}
		cout << endl;
	}
	return 0;
}
0