結果
問題 |
No.1491 銀将
|
ユーザー |
![]() |
提出日時 | 2021-05-03 15:37:10 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,448 bytes |
コンパイル時間 | 789 ms |
コンパイル使用メモリ | 93,332 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-22 06:15:13 |
合計ジャッジ時間 | 1,545 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
/* -*- coding: utf-8 -*- * * 1491.cc: No.1491 銀将 - yukicoder */ #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<iostream> #include<string> #include<vector> #include<map> #include<set> #include<stack> #include<list> #include<queue> #include<deque> #include<algorithm> #include<numeric> #include<utility> #include<complex> #include<functional> using namespace std; /* constant */ const int N = 11; const int D = 5; const int dxs[D] = { 0, 1, -1, 1, -1 }; const int dys[D] = { 1, 1, 1, -1, -1 }; /* typedef */ typedef long long ll; /* global variables */ bool fs[2][N][N]; /* subroutines */ void printfs(int cur) { for (int y = N - 1; y >= 0; y--) { for (int x = 0; x < N; x++) putchar(fs[cur][y][x] ? 'o' : 'x'); putchar('\n'); } } /* main */ int main() { int k; scanf("%d", &k); int n = 2 * k + 1; ll a = (ll)n * n - n - (n - 2) / 2 * 2; printf("%lld\n", a); if (false) { fs[0][N / 2][N / 2] = true; printfs(0); putchar('\n'); int cur = 0, nxt = 1; while (k--) { memcpy(fs[nxt], fs[cur], sizeof(fs[cur])); for (int y = 0; y < N; y++) for (int x = 0; x < N; x++) if (fs[cur][y][x]) for (int di = 0; di < D; di++) { int vy = y + dys[di], vx = x + dxs[di]; if (vy >= 0 && vy < N && vx >= 0 && vx < N) fs[nxt][vy][vx] = true; } swap(cur, nxt); printfs(cur); putchar('\n'); } } return 0; }