結果

問題 No.3723 Climb or Detour
コンテスト
ユーザー DB0917
提出日時 2026-09-19 15:06:08
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 27 ms / 2,000 ms
+ 788µs
コード長 1,292 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,621 ms
コンパイル使用メモリ 347,616 KB
実行使用メモリ 24,832 KB
最終ジャッジ日時 2026-09-19 15:06:34
合計ジャッジ時間 8,460 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using i128 = __int128;
using db = double;
using ld = long double;
#define int ll
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

const int INF=LLONG_MAX/4;
const int MOD=998244353;

random_device rd;
mt19937_64 gen(rd());

void pre_do(){

}

void solve(){	

	int n, k; cin >> n >> k;
	vector<vector<char>> ans(n, vector<char>(n, '.'));
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	sx--, sy--, tx--, ty--;
	int mn = abs(tx-sx)+abs(ty-sy), mx = mn*2 - (mn&1);
	if(k<mn || k>mx || (mn&1)!=(k&1)){
		cout << "-1\n";
		return;
	}
	int d = k-mn;
	vector<vector<pair<int, int>>> pos(n*2+5);
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			int dx = abs(i-sx), dy = abs(j-sy);
			pos[dx+dy].push_back({i, j});
		}
	}
	for(int i=1;i<d;i+=2){
		//cout << i << '\n';
		for(auto& [x, y] : pos[i]){
			//cout << x << ' ' << y << '\n';
			ans[x][y] = '#';
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cout << ans[i][j];
		}
		cout << '\n';
	}
}
 	
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	pre_do();

	int t=1;
	//cin >> t;
	while(t--){
		solve();
	}
	//cout << "FINISH\n";
}
0