結果

問題 No.2432 Flip and Move
ユーザー tnakao0123tnakao0123
提出日時 2023-08-22 19:07:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 991 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 42,376 KB
実行使用メモリ 6,868 KB
最終ジャッジ日時 2023-08-22 19:07:37
合計ジャッジ時間 7,515 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 20 ms
6,756 KB
testcase_03 AC 43 ms
6,820 KB
testcase_04 AC 12 ms
6,868 KB
testcase_05 AC 11 ms
6,868 KB
testcase_06 AC 10 ms
4,888 KB
testcase_07 AC 30 ms
5,500 KB
testcase_08 AC 25 ms
5,668 KB
testcase_09 AC 39 ms
6,736 KB
testcase_10 AC 13 ms
5,376 KB
testcase_11 AC 16 ms
5,816 KB
testcase_12 AC 12 ms
5,056 KB
testcase_13 AC 12 ms
5,712 KB
testcase_14 AC 9 ms
4,380 KB
testcase_15 AC 27 ms
6,132 KB
testcase_16 AC 11 ms
4,524 KB
testcase_17 AC 19 ms
6,280 KB
testcase_18 AC 5 ms
4,376 KB
testcase_19 AC 16 ms
5,432 KB
testcase_20 AC 20 ms
6,716 KB
testcase_21 AC 17 ms
5,460 KB
testcase_22 AC 15 ms
5,804 KB
testcase_23 AC 6 ms
4,384 KB
testcase_24 AC 18 ms
6,072 KB
testcase_25 AC 15 ms
5,320 KB
testcase_26 AC 14 ms
5,920 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 18 ms
5,380 KB
testcase_30 AC 20 ms
6,484 KB
testcase_31 AC 13 ms
5,780 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 22 ms
6,280 KB
testcase_34 AC 10 ms
4,632 KB
testcase_35 AC 10 ms
5,324 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2432.cc:  No.2432 Flip and Move - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 1000000;
const int INF = 1 << 30;

/* typedef */

typedef long long ll;

/* global variables */

int fs[MAX_N];

/* subroutines */

int calc(int h, int w, int limit = INF) {
  int y = 0, x = 0, dy = 1, dx = 1, l = 0;
  while (l < limit) {
    l++;
    fs[y * w + x] ^= 1;
    y += dy;
    if (y < 0 || y >= h) y -= dy, dy = -dy;
    x += dx;
    if (x < 0 || x >= w) x -= dx, dx = -dx;
    if (y == 0 && x == 0 && dy > 0 && dx > 0) break;
  }
  return l;
}

/* main */

int main() {
  int h, w;
  ll k;
  scanf("%d%d%lld", &h, &w, &k);
  int n = h * w;

  int l = calc(h, w);
  //printf("l=%d\n", l);

  ll q = k / l;
  int r = k % l;
  if (! (q & 1)) fill(fs, fs + n, 0);

  calc(h, w, r);

  for (int i = 0; i < n; i++) {
    putchar(fs[i] ? '#' : '.');
    if ((i + 1 ) % w == 0) putchar('\n');
  }
  return 0;
}
0