結果
問題 |
No.2432 Flip and Move
|
ユーザー |
![]() |
提出日時 | 2023-08-22 19:07:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 2,000 ms |
コード長 | 991 bytes |
コンパイル時間 | 412 ms |
コンパイル使用メモリ | 42,436 KB |
実行使用メモリ | 7,012 KB |
最終ジャッジ日時 | 2024-12-17 19:57:13 |
合計ジャッジ時間 | 4,312 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
/* -*- 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; }