結果
問題 | No.1491 銀将 |
ユーザー |
![]() |
提出日時 | 2021-04-30 22:01:00 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,078 bytes |
コンパイル時間 | 696 ms |
コンパイル使用メモリ | 75,412 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 01:27:16 |
合計ジャッジ時間 | 1,414 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
#include <iostream>#include <queue>#include <vector>#define rep(i, n) for(i = 0; i < n; i++)#define int long longusing 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;}