結果
問題 | No.565 回転拡大 |
ユーザー |
![]() |
提出日時 | 2018-03-24 13:14:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,872 bytes |
コンパイル時間 | 736 ms |
コンパイル使用メモリ | 72,192 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 03:07:33 |
合計ジャッジ時間 | 1,829 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
// No.565 回転拡大 // https://yukicoder.me/problems/no/565 // #include <iostream> #include <vector> #include <string> using namespace std; vector<vector<char>> rotate_pict(int R, vector<vector<char>> &pict); int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int R, K; cin >> R >> K; int H, W; cin >> H >> W; vector<vector<char>> pict(H); for (auto i = 0; i < H; ++i) pict[i].resize(W); for (int y = 0; y < H; ++y) for (int x = 0; x < W; ++x) cin >> pict[y][x]; vector<vector<char>> rpict = rotate_pict(R, pict); for (auto y = 0; y < rpict.size(); ++y) { for (auto ky = 0; ky < K; ++ky) { for (auto x = 0; x < rpict[0].size(); ++x) { for (auto kx = 0; kx < K; ++kx) { cout << rpict[y][x]; } } cout << endl; } } } vector<vector<char>> rotate_pict(int R, vector<vector<char>> &pict) { int h, w; if (R == 90 || R == 270) { w = pict.size(); h = pict[0].size(); } else { h = pict.size(); w = pict[0].size(); } vector<vector<char>> rpict(h); for (auto i = 0; i < h; ++i) rpict[i].resize(w); for (auto y = 0; y < h; ++y) { for (auto x = 0; x < w; ++x) { switch (R) { case 0: rpict[y][x] = pict[y][x]; break; case 180: rpict[y][x] = pict[h-y-1][w-x-1]; break; case 90: rpict[y][x] = pict[w-x-1][y]; break; case 270: rpict[y][x] = pict[x][h-y-1]; break; default: break; } } } return rpict; }