結果

問題 No.565 回転拡大
ユーザー peroonperoon
提出日時 2019-06-11 09:23:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,920 bytes
コンパイル時間 2,074 ms
コンパイル使用メモリ 170,884 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 20:33:51
合計ジャッジ時間 2,705 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
//using VV = vector<vector<ll> >;
using VV = vector<vector<char> >;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<char> A){
    ll L = A.size();
    FOR(i, 0, L){
        //if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

// 時計回りに回転
VV rot90(VV mat){
    ll H = mat.size();
    ll W = mat[0].size();
    
    ll new_W = H;
    ll new_H = W;

    VV M(new_H);
    FOR(y, 0, new_H){
        for(ll i=H-1; i>=0; i--){
            char c = mat[i][y];
            M[y].push_back(c);
        }
    }
    return M;
}

VV expand(VV m, ll scale){
    ll H = m.size();
    ll W = m[0].size();

    ll new_H = H * scale;
    ll new_W = W * scale;
    
    VV M(new_H);

    FOR(y, 0, new_H){
        FOR(x, 0, new_W){
            char c = m[y/scale][x/scale];
            M[y].push_back(c);
        }
    }
    return M;
}

void print_mat(VV x){
    ll H = x.size();
    FOR(i, 0, H){
        vprint(x[i]);
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll R, K, H, W;
    cin >> R >> K >> H >> W;
    
    VV mat(H);
    FOR(y, 0, H){
        string s; cin >> s;
        mat[y].resize(s.size());
        FOR(x, 0, W){
            mat[y][x] = s[x];
        }
    }

    ll rot_num = R / 90;
    FOR(i, 0, rot_num){
        mat = rot90(mat);
    }

    mat = expand(mat, K);

    print_mat(mat);
    
    return 0;
}
0