結果

問題 No.1491 銀将
ユーザー startcppstartcpp
提出日時 2021-04-30 22:01:00
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,078 bytes
コンパイル時間 667 ms
コンパイル使用メモリ 75,268 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-26 06:05:17
合計ジャッジ時間 1,930 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <queue>
#include <vector>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;

int C = 50;
int dist[100][100];
int dy[5] = {1, 1, 1, -1, -1};
int dx[5] = {-1, 0, 1, -1, 1};

void jikken(int n) {
	int i, j;
	rep(i, 100) rep(j, 100) dist[i][j] = -1;
	
	queue<P> que;
	dist[C][C] = 0;
	que.push(P(C, C));
	while (!que.empty()) {
		P now = que.front();
		que.pop();
		rep(i, 5) {
			int ny = now.first + dy[i];
			int nx = now.second + dx[i];
			if (dist[ny][nx] == -1 && dist[now.first][now.second] < n) {
				dist[ny][nx] = dist[now.first][now.second] + 1;
				que.push(P(ny, nx));
			}
		}
	}
	
	int ans = 0;
	for (i = C - n; i <= C + n; i++) {
		for (j = C - n; j <= C + n; j++) {
			if (dist[i][j] == -1) cout << "-";
			else cout << dist[i][j];
			cout << " ";
			if (dist[i][j] != -1) ans++;
		}
		cout << endl;
	}

	cout << (2 * n + 1) * (2 * n + 1) - ans << endl;
}

signed main() {
	int n;
	cin >> n;
	//jikken(n);
	cout << (2 * n + 1) * (2 * n + 1) - (4 * n - 1) << endl;
	return 0;
}
0