結果

問題 No.2432 Flip and Move
コンテスト
ユーザー chro_96
提出日時 2023-08-18 23:49:44
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,220 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 182 ms
コンパイル使用メモリ 40,140 KB
最終ジャッジ日時 2026-02-22 11:11:51
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 1 WA * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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