結果

問題 No.1491 銀将
ユーザー tnakao0123tnakao0123
提出日時 2021-05-03 15:37:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,448 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 89,932 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-29 11:52:22
合計ジャッジ時間 1,978 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/* -*- 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;
}
0