結果

問題 No.2432 Flip and Move
ユーザー 👑 chro_96chro_96
提出日時 2023-08-18 23:59:03
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,936 bytes
コンパイル時間 478 ms
コンパイル使用メモリ 31,744 KB
実行使用メモリ 18,596 KB
最終ジャッジ日時 2024-05-06 06:51:20
合計ジャッジ時間 3,978 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
18,368 KB
testcase_01 AC 6 ms
18,408 KB
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 AC 5 ms
18,284 KB
testcase_37 AC 6 ms
18,432 KB
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);
  
  while (((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;
  }
  
  s = flag[pos][st];
  t = cnt+1;
    
  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] >= s) {
          long long tmp = k-((long long)(s-1));
          if (flag[i*w+j][l]-s <= tmp%((long long)(t-s))) {
            tmp = 1LL+tmp/((long long)(t-s));
          } else {
            tmp /= ((long long)(t-s));
          }
          if (tmp%2LL == 1LL) {
            f ^= 1;
          }
        } else 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