結果

問題 No.2432 Flip and Move
ユーザー 👑 chro_96chro_96
提出日時 2023-08-18 23:49:44
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,220 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 30,976 KB
実行使用メモリ 18,560 KB
最終ジャッジ日時 2024-05-06 06:39:59
合計ジャッジ時間 2,424 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
18,304 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int main () {
  int h = 0;
  int w = 0;
  long long k = 0LL;

  int res = 0;
  
  int cnt = 0;
  int flag[1000000][4] = {};
  char ans[1000001] = "";
  int st = 0;
  int pos = 0;
  int s = 0;
  int t = 0;
  
  res = scanf("%d", &h);
  res = scanf("%d", &w);
  res = scanf("%lld", &k);
  
  if (((long long)cnt) < k && flag[pos][st] <= 0) {
    cnt++;
    flag[pos][st] = cnt;
    if (st%2 == 0) {
      pos += w;
      if (pos/w >= h) {
        pos -= w;
        st ^= 1;
      }
    } else {
      pos -= w;
      if (pos < 0) {
        pos += w;
        st ^= 1;
      }
    }
    if (st < 2) {
      if (pos%w == w-1) {
        st ^= 2;
      } else {
        pos++;
      }
    } else {
      if (pos%w == 0) {
        st ^= 2;
      } else {
        pos--;
      }
    }
  }
  
  if ((long long)cnt == k) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        int f = 0;
        for (int l = 0; l < 4; l++) {
          if (flag[i*w+j][l] > 0) {
            f ^= 1;
          }
        }
        if (f == 0) {
          ans[j] = '.';
        } else {
          ans[j] = '#';
        }
      }
      ans[w] = '\0';
      printf("%s\n", ans);
    }
  }
  
  
  return 0;
}
0