1861.cpp (753B)
1 #pragma GCC optimize(fast); 2 static auto _ = []() { 3 std::ios_base::sync_with_stdio(0); 4 std::cin.tie(0); 5 return 0; 6 }(); 7 8 class Solution { 9 public: 10 vector<vector<char>> rotateTheBox(const vector<vector<char>> &box) const { 11 const int n = box.size(), m = box[0].size(); 12 vector<vector<char>> res(m, vector(n, '.')); 13 14 for (int i = 0; i < n; i++) { 15 for (int j = m - 1, limit = m; j >= 0; j--) { 16 if (box[i][j] == '.') continue; 17 if (box[i][j] == '*') { 18 res[j][n - i - 1] = '*'; 19 limit = j; 20 continue; 21 } 22 res[--limit][n - i - 1] = '#'; 23 } 24 } 25 26 return res; 27 } 28 };