結果
問題 | No.2432 Flip and Move |
ユーザー | k1suxu |
提出日時 | 2023-08-19 00:25:05 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 553 ms / 2,000 ms |
コード長 | 2,620 bytes |
コンパイル時間 | 3,338 ms |
コンパイル使用メモリ | 269,016 KB |
実行使用メモリ | 144,688 KB |
最終ジャッジ日時 | 2024-05-06 07:20:55 |
合計ジャッジ時間 | 13,523 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 233 ms
144,688 KB |
testcase_03 | AC | 307 ms
135,936 KB |
testcase_04 | AC | 100 ms
74,624 KB |
testcase_05 | AC | 102 ms
74,624 KB |
testcase_06 | AC | 87 ms
58,592 KB |
testcase_07 | AC | 189 ms
89,216 KB |
testcase_08 | AC | 198 ms
96,512 KB |
testcase_09 | AC | 280 ms
131,200 KB |
testcase_10 | AC | 149 ms
92,620 KB |
testcase_11 | AC | 175 ms
105,764 KB |
testcase_12 | AC | 130 ms
79,472 KB |
testcase_13 | AC | 128 ms
80,168 KB |
testcase_14 | AC | 63 ms
32,896 KB |
testcase_15 | AC | 233 ms
112,640 KB |
testcase_16 | AC | 191 ms
31,616 KB |
testcase_17 | AC | 494 ms
65,152 KB |
testcase_18 | AC | 85 ms
21,120 KB |
testcase_19 | AC | 386 ms
51,328 KB |
testcase_20 | AC | 553 ms
71,936 KB |
testcase_21 | AC | 364 ms
50,048 KB |
testcase_22 | AC | 337 ms
57,984 KB |
testcase_23 | AC | 40 ms
17,280 KB |
testcase_24 | AC | 476 ms
62,592 KB |
testcase_25 | AC | 327 ms
46,720 KB |
testcase_26 | AC | 234 ms
57,472 KB |
testcase_27 | AC | 9 ms
7,168 KB |
testcase_28 | AC | 5 ms
5,376 KB |
testcase_29 | AC | 347 ms
48,640 KB |
testcase_30 | AC | 531 ms
67,712 KB |
testcase_31 | AC | 234 ms
54,400 KB |
testcase_32 | AC | 12 ms
7,936 KB |
testcase_33 | AC | 508 ms
66,048 KB |
testcase_34 | AC | 220 ms
35,968 KB |
testcase_35 | AC | 150 ms
47,744 KB |
testcase_36 | AC | 2 ms
5,376 KB |
testcase_37 | AC | 2 ms
5,376 KB |
testcase_38 | AC | 1 ms
5,376 KB |
ソースコード
// #pragma GCC target("avx") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) #define FOR(n) for(int i = 0; i < (int)n; i++) #define repi(i,a,b) for(int i = (int)a; i < (int)b; i++) #define all(x) x.begin(),x.end() //#define mp make_pair #define vi vector<int> #define vvi vector<vi> #define vvvi vector<vvi> #define vvvvi vector<vvvi> #define pii pair<int,int> #define vpii vector<pair<int,int>> template<typename T> void chmax(T &a, const T &b) {a = (a > b? a : b);} template<typename T> void chmin(T &a, const T &b) {a = (a < b? a : b);} using ll = long long; using ld = long double; using ull = unsigned long long; const ll INF = numeric_limits<long long>::max() / 2; const ld pi = 3.1415926535897932384626433832795028; const ll mod = 998244353; int dx[] = {-1, -1, 1, 1}; int dy[] = {-1, 1, -1, 1}; #define int long long void solve() { map<pii, int> inv; rep(d, 4) inv[make_pair(dx[d], dy[d])] = d; int h, w, k; cin >> h >> w >> k; vector<string> cycle(h, string(w, '.')); int cnt = 0; { vector<vector<vector<bool>>> done(h, vector<vector<bool>>(w, vector<bool>(4, false))); array<int, 3> cur = {0, 0, 3}; while(!done[cur[0]][cur[1]][cur[2]]) { cycle[cur[0]][cur[1]] = (char)('.' + '#' - cycle[cur[0]][cur[1]]); done[cur[0]][cur[1]][cur[2]] = true; ++cnt; int ddx = dx[cur[2]], ddy = dy[cur[2]]; int nx = cur[0] + ddx; int ny = cur[1] + ddy; if(nx < 0 || nx >= h) { nx = cur[0]; ddx *= -1; } if(ny < 0 || ny >= w) { ny = cur[1]; ddy *= -1; } cur = {nx, ny, inv[make_pair(ddx, ddy)]}; } } vector<string> ans(h, string(w, '.')); int how_many = k/cnt; if(how_many%2 ==1) ans = cycle; k %= cnt; array<int, 3> cur = {0, 0, 3}; rep(times, k) { ans[cur[0]][cur[1]] = (char)('.' + '#' - ans[cur[0]][cur[1]]); int ddx = dx[cur[2]], ddy = dy[cur[2]]; int nx = cur[0] + ddx; int ny = cur[1] + ddy; if(nx < 0 || nx >= h) { nx = cur[0]; ddx *= -1; } if(ny < 0 || ny >= w) { ny = cur[1]; ddy *= -1; } cur = {nx, ny, inv[make_pair(ddx, ddy)]}; } for(auto e : ans) cout << e << "\n"; } signed main() { cin.tie(nullptr); ios::sync_with_stdio(false); solve(); return 0; }