1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
| #include <bits/stdc++.h> using namespace std;
#define ll long long #define ui unsigned int #define ull unsigned long long #define INF 1023456789 #define jizz \ cin.tie(0); \ ios_base::sync_with_stdio(0)
int main() { jizz; int p, w, ans = 0; cin >> p >> w; vector<vector<bool>> M(p * 4 + 10, vector<bool>(w, 0)); vector<bool> tmpv(w, 1); vector<bool> em(w, 0); unordered_map<vector<bool>, bool> check; check[tmpv] = 1; char tmpc; string moves; unordered_map<char, pair<vector<int>, vector<int>>> cubes; cubes['L'] = make_pair(vector<int>({ 0, 3, 1 }), vector<int>({ 0, 0, 0 })); cubes['J'] = make_pair(vector<int>({ 0, 1, 3 }), vector<int>({ 0, 0, 0 })); cubes['O'] = make_pair(vector<int>({ 0, 2, 2 }), vector<int>({ 0, 0, 0 })); cubes['I'] = make_pair(vector<int>({ 0, 0, 4 }), vector<int>({ 0, 0, 0 })); cubes['Z'] = make_pair(vector<int>({ 1, 2, 1 }), vector<int>({ -1, 0, 0 })); cubes['S'] = make_pair(vector<int>({ 1, 2, 1 }), vector<int>({ 0, 0, -1 })); cubes['T'] = make_pair(vector<int>({ 1, 2, 1 }), vector<int>({ -1, 0, -1 })); vector<int> h(w + 5, 0); while (p--) { cin >> tmpc; cin >> moves; int place = 0; int width; auto nowc = cubes[tmpc]; if (nowc.first[0] != 0) width = 3; else if (nowc.first[1] != 0) width = 2; else width = 1; for (auto& it : moves) { if (it == '>') { if (place != 0) place--; } else { if (place + width != w) place++; } } int maxh = -INF; for (int i = 0; i < width; i++) maxh = max(maxh, h[place + i] + nowc.second[width - i - 1]); for (int i = 0; i < width; i++) { if (nowc.first[2 - i]) { for (int j = maxh - nowc.second[2 - i]; j < maxh - nowc.second[2 - i] + nowc.first[2 - i]; j++) { M[j][place + i] = 1; } } } for (int i = 0; i < 5; i++) { if (check.find(M[maxh + i]) != check.end()) { M.erase(M.begin() + maxh + i); i--; M.push_back(em); } } for (int i = 0; i < w; i++) { int tmph = 0; for (int j = 0; j < M.size(); j++) { if (M[j][i]) { tmph = max(tmph, j + 1); } } h[i] = tmph; } } for (auto it : h) ans = max(it, ans); cout << ans << "\n"; }
|