結果
問題 | No.2432 Flip and Move |
ユーザー | 👑 emthrm |
提出日時 | 2023-08-18 23:19:15 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 966 ms / 2,000 ms |
コード長 | 1,773 bytes |
コンパイル時間 | 3,143 ms |
コンパイル使用メモリ | 252,060 KB |
実行使用メモリ | 143,680 KB |
最終ジャッジ日時 | 2024-05-06 06:01:03 |
合計ジャッジ時間 | 15,846 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 181 ms
116,476 KB |
testcase_03 | AC | 272 ms
143,680 KB |
testcase_04 | AC | 103 ms
61,952 KB |
testcase_05 | AC | 103 ms
61,824 KB |
testcase_06 | AC | 77 ms
47,836 KB |
testcase_07 | AC | 201 ms
94,416 KB |
testcase_08 | AC | 206 ms
102,160 KB |
testcase_09 | AC | 289 ms
138,796 KB |
testcase_10 | AC | 115 ms
74,856 KB |
testcase_11 | AC | 144 ms
85,140 KB |
testcase_12 | AC | 99 ms
64,376 KB |
testcase_13 | AC | 115 ms
65,280 KB |
testcase_14 | AC | 63 ms
34,732 KB |
testcase_15 | AC | 235 ms
118,868 KB |
testcase_16 | AC | 343 ms
26,624 KB |
testcase_17 | AC | 639 ms
54,016 KB |
testcase_18 | AC | 87 ms
17,792 KB |
testcase_19 | AC | 463 ms
42,752 KB |
testcase_20 | AC | 566 ms
59,776 KB |
testcase_21 | AC | 735 ms
41,728 KB |
testcase_22 | AC | 308 ms
48,128 KB |
testcase_23 | AC | 83 ms
14,976 KB |
testcase_24 | AC | 551 ms
52,096 KB |
testcase_25 | AC | 421 ms
39,040 KB |
testcase_26 | AC | 308 ms
48,000 KB |
testcase_27 | AC | 8 ms
6,940 KB |
testcase_28 | AC | 4 ms
6,944 KB |
testcase_29 | AC | 708 ms
40,704 KB |
testcase_30 | AC | 904 ms
56,320 KB |
testcase_31 | AC | 390 ms
45,312 KB |
testcase_32 | AC | 11 ms
7,040 KB |
testcase_33 | AC | 966 ms
54,912 KB |
testcase_34 | AC | 402 ms
30,080 KB |
testcase_35 | AC | 227 ms
39,936 KB |
testcase_36 | AC | 1 ms
6,940 KB |
testcase_37 | AC | 2 ms
6,940 KB |
testcase_38 | AC | 2 ms
6,944 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #define FOR(i,m,n) for(int i=(m);i<(n);++i) #define REP(i,n) FOR(i,0,n) using ll = long long; constexpr int INF = 0x3f3f3f3f; constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL; constexpr double EPS = 1e-8; constexpr int MOD = 998244353; // constexpr int MOD = 1000000007; constexpr int DY4[]{1, 0, -1, 0}, DX4[]{0, -1, 0, 1}; constexpr int DY8[]{1, 1, 0, -1, -1, -1, 0, 1}; constexpr int DX8[]{0, -1, -1, -1, 0, 1, 1, 1}; template <typename T, typename U> inline bool chmax(T& a, U b) { return a < b ? (a = b, true) : false; } template <typename T, typename U> inline bool chmin(T& a, U b) { return a > b ? (a = b, true) : false; } struct IOSetup { IOSetup() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << fixed << setprecision(20); } } iosetup; int main() { int h, w; ll k; cin >> h >> w >> k; vector s(h, vector(w, 0)); s[0][0] = 1; vector dp(h, vector(w, vector(4, -1))); dp[0][0][0] = 0; bool init = true; int i = 0, j = 0, dir = 0, history = 1; while (history < k) { if (dir & 1) { // 上 if (i == 0) { dir ^= 1; } else { --i; } } else { // 下 if (i + 1 == h) { dir ^= 1; } else { ++i; } } if (dir & 2) { // 左 if (j == 0) { dir ^= 2; } else { --j; } } else { // 右 if (j + 1 == w) { dir ^= 2; } else { ++j; } } if (init && dp[i][j][dir] != -1) { init = false; k = (k - history) % ((history - dp[i][j][dir]) * 2) + history; } s[i][j] ^= 1; dp[i][j][dir] = history++; } REP(i, h) { REP(j, w) cout << (s[i][j] ? '#' : '.'); cout << '\n'; } return 0; }