結果

問題 No.3731 Kaleidoscope
コンテスト
ユーザー tnakao0123
提出日時 2026-09-21 16:42:51
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
+ 584µs
コード長 971 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 168 ms
コンパイル使用メモリ 54,572 KB
実行使用メモリ 9,928 KB
最終ジャッジ日時 2026-09-21 16:43:11
合計ジャッジ時間 3,752 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

/* -*- coding: utf-8 -*-
 *
 * 3731.cc:  No.3731 Kaleidoscope - yukicoder
 */

#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

/* constant */

const int MAX_L = 1000;
const int MAX_N = 1 << 10;

/* typedef */

/* global variables */

char s[MAX_L + 4], ss[MAX_N][MAX_N + 4];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);
  int l = strlen(s);

  int n = (l + 1) / 2 * 2 + 3;
  for (int i = 0; i < n; i++) fill(ss[i], ss[i] + n, '#');
  ss[0][0] = '.';
  for (int i = 0; i < n; i++) ss[i][n - 1] = ss[n - 1][i] = '.';

  int y = 0, x = 0, dy = 0, dx = 1;
  for (int i = 0; i < l; i++) {
    y += dy, x += dx;
    ss[y][x] = '.';
    y += dy, x += dx;
    ss[y][x] = '.';

    if (s[i] == 'o') {
      int vy = y, vx = x;
      while (vy < n - 1 && vx < n - 1) {
	vy += dy, vx += dx;
	ss[vy][vx] = '.';
      }
    }
    
    swap(dy, dx);
  }

  printf("%d\n", n);
  for (int i = 0; i < n; i++) puts(ss[i]);
  
  return 0;
}

0