結果
問題 | No.2432 Flip and Move |
ユーザー | arad |
提出日時 | 2023-08-19 15:37:31 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,479 ms / 2,000 ms |
コード長 | 2,696 bytes |
コンパイル時間 | 4,297 ms |
コンパイル使用メモリ | 267,820 KB |
実行使用メモリ | 144,912 KB |
最終ジャッジ日時 | 2024-11-29 09:12:23 |
合計ジャッジ時間 | 24,329 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 235 ms
144,912 KB |
testcase_03 | AC | 1,479 ms
136,064 KB |
testcase_04 | AC | 107 ms
75,520 KB |
testcase_05 | AC | 108 ms
75,520 KB |
testcase_06 | AC | 89 ms
58,684 KB |
testcase_07 | AC | 1,007 ms
89,344 KB |
testcase_08 | AC | 1,056 ms
96,640 KB |
testcase_09 | AC | 1,474 ms
131,200 KB |
testcase_10 | AC | 147 ms
92,676 KB |
testcase_11 | AC | 189 ms
105,836 KB |
testcase_12 | AC | 127 ms
79,664 KB |
testcase_13 | AC | 138 ms
80,288 KB |
testcase_14 | AC | 334 ms
33,024 KB |
testcase_15 | AC | 1,276 ms
112,640 KB |
testcase_16 | AC | 376 ms
31,744 KB |
testcase_17 | AC | 671 ms
65,280 KB |
testcase_18 | AC | 90 ms
21,120 KB |
testcase_19 | AC | 547 ms
51,840 KB |
testcase_20 | AC | 620 ms
72,320 KB |
testcase_21 | AC | 935 ms
50,688 KB |
testcase_22 | AC | 298 ms
58,368 KB |
testcase_23 | AC | 81 ms
17,664 KB |
testcase_24 | AC | 566 ms
63,232 KB |
testcase_25 | AC | 479 ms
47,104 KB |
testcase_26 | AC | 367 ms
57,984 KB |
testcase_27 | AC | 9 ms
7,168 KB |
testcase_28 | AC | 6 ms
5,248 KB |
testcase_29 | AC | 868 ms
48,896 KB |
testcase_30 | AC | 1,142 ms
68,096 KB |
testcase_31 | AC | 465 ms
54,784 KB |
testcase_32 | AC | 13 ms
7,936 KB |
testcase_33 | AC | 1,181 ms
66,688 KB |
testcase_34 | AC | 436 ms
36,096 KB |
testcase_35 | AC | 224 ms
48,256 KB |
testcase_36 | AC | 2 ms
5,248 KB |
testcase_37 | AC | 2 ms
5,248 KB |
testcase_38 | AC | 2 ms
5,248 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <atcoder/all> using namespace atcoder; using ll = long long; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; using VD = vector<double>; using VVD = vector<VD>; using VS = vector<string>; using P = pair<ll,ll>; using VP = vector<P>; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define out(x) cout << x << endl #define dout(x) cout << fixed << setprecision(10) << x << endl #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define sz(x) (int)(x.size()) #define re0 return 0 #define pcnt __builtin_popcountll template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr int inf = 1e9; constexpr ll INF = 1e18; //using mint = modint1000000007; using mint = modint998244353; int di[4] = {1,0,-1,0}; int dj[4] = {0,1,0,-1}; int main(){ ll h,w,k; cin >> h >> w >> k; VS s(h); rep(i,h)rep(j,w) s[i].push_back('.'); vector<vector<vector<ll>>> memo(h,vector<vector<ll>>(w,vector<ll>(4,-1))); memo[0][0][0] = 0; bool flag = false; ll i = 0,j = 0,state = 0; while(k > 0){ if(s[i][j] == '.') s[i][j] = '#'; else s[i][j] = '.'; ll pi = i,pj = j,pstate = state; //jouge if(state>>1&1){ //ue ll ni = i-1; ll nj = j; if(ni < 0 || nj < 0 || ni >= h || nj >= w){ state ^= 1<<1; } else { i = ni; j = nj; } } else { //shita ll ni = i+1; ll nj = j; if(ni < 0 || nj < 0 || ni >= h || nj >= w){ state ^= 1<<1; } else { i = ni; j = nj; } } if(state&1){ //hidari ll ni = i; ll nj = j-1; if(ni < 0 || nj < 0 || ni >= h || nj >= w){ state ^= 1; } else { i = ni; j = nj; } } else { //migi ll ni = i; ll nj = j+1; if(ni < 0 || nj < 0 || ni >= h || nj >= w){ state ^= 1; } else { i = ni; j = nj; } } if(memo[i][j][state] == -1 || flag){ memo[i][j][state] = memo[pi][pj][pstate]+1; } else { flag = true; k %= (memo[pi][pj][pstate]-memo[i][j][state]+1)*2; } k--; } rep(i,h) out(s[i]); }