結果

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

テストケース

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

ソースコード

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, k / 90)) {
        std::string t = extend(s, k);
        for(int i = 0; i < k; i ++) std::cout << t << std::endl;
    }
    return 0;
}

0