結果

問題 No.565 回転拡大
ユーザー shinchanshinchan
提出日時 2023-04-28 10:18:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,941 bytes
コンパイル時間 849 ms
コンパイル使用メモリ 81,316 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-11 00:13:47
合計ジャッジ時間 2,051 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "yukicoder-rotate-enlarge_2.test.cpp"
#define PROBLEM "https://yukicoder.me/problems/no/565"

#line 2 "/mnt/c/Users/shinc/atcoder/library/cpp/grid.hpp"

#include <vector>
#include <algorithm>

template<class T> std::vector<T> transpose(const std::vector<T> &v) {
    int n = v.size();
    if(n == 0) return v;
    int m = v[0].size();
    std::vector<T> ret(m);
    for(int i = 0; i < m; i ++) {
        ret[i].resize(n);
        for(int j = 0; j < n; j ++) ret[i][j] = v[j][i];
    }
    return ret;
}

template<class T> std::vector<T> rev_lr(std::vector<T> v) {
    int n = v.size();
    for(int i = 0; i < n; i ++) reverse(v[i].begin(), v[i].end());
    return v;
}

template<class T> std::vector<T> rev_ud(std::vector<T> v) {
    reverse(v.begin(), v.end());
    return v;
}

template<class T> std::vector<T> rotate(const std::vector<T> &v, int k) {
    k %= 4;
    if(k == 0) return v;
    if(k < 0) k += 4;
    if(k == 2) return rev_lr(rev_ud(v));
    int n = v.size(); if(n == 0) return v;
    int m = v[0].size();
    std::vector<T> ret(m);
    if(k == 1) {
        for(int i = 0; i < m; i ++) {
            ret[i].resize(n);
            for(int j = 0; j < n; j ++) ret[i][j] = v[n - j - 1][i];
        }
    } else {
        for(int i = 0; i < m; i ++) {
            ret[i].resize(n);
            for(int j = 0; j < n; j ++) ret[i][j] = v[j][m - i - 1];
        }
    }
    return ret;
}
#line 4 "yukicoder-rotate-enlarge_2.test.cpp"
#include <iostream>
#include <string>

std::string extend(std::string s, int k) {
    std::string ret = "";
    for(char c : s) ret += std::string(k, c);
    return ret;
}

int main() {
    int r, k, h, w;
    std::cin >> r >> k >> h >> w;
    std::vector<std::string> c(h);
    for(int i = 0; i < h; i ++) std::cin >> c[i];

    for(auto s : rotate(c, r / 90)) {
        std::string t = extend(s, k);
        for(int i = 0; i < k; i ++) std::cout << t << std::endl;
    }
    return 0;
}

0