結果

問題 No.675 ドットちゃんたち
ユーザー mamekinmamekin
提出日時 2018-04-13 23:36:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,738 bytes
コンパイル時間 1,308 ms
コンパイル使用メモリ 114,592 KB
実行使用メモリ 24,288 KB
最終ジャッジ日時 2023-09-09 04:51:27
合計ジャッジ時間 4,020 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 205 ms
24,040 KB
testcase_06 AC 238 ms
24,160 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

// 行列の積
template <class T>
vector<vector<T> > matrixProduct(const vector<vector<T> >& x, const vector<vector<T> >& y)
{
    int a = x.size();
    int b = x[0].size();
    int c = y[0].size();
    vector<vector<T> > z(a, vector<T>(c, 0));
    for(int i=0; i<a; ++i){
        for(int j=0; j<c; ++j){
            for(int k=0; k<b; ++k){
                z[i][j] += x[i][k] * y[k][j];
            }
        }
    }
    return z;
}

int main()
{
    int n, px, py;
    cin >> n >> px >> py;

    vector<vector<vector<long long> > > v(n);
    for(int i=0; i<n; ++i){
        int type, d;
        cin >> type >> d;
        if(type == 1)
            v[i] = {{1, 0, d}, {0, 1, 0}, {0, 0, 1}};
        else if(type == 2)
            v[i] = {{1, 0, 0}, {0, 1, d}, {0, 0, 1}};
        else
            v[i] = {{0, 1, 0}, {-1, 0, 0}, {0, 0, 1}};
    }

    vector<pair<long long, long long> > ans(n);
    vector<vector<long long> > mat = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
    for(int i=n-1; i>=0; --i){
        mat = matrixProduct(mat, v[i]);
        ans[i].first  = mat[0][0] * px + mat[0][1] * py + mat[0][2];
        ans[i].second = mat[1][0] * px + mat[1][1] * py + mat[1][2];
    }
    for(int i=0; i<n; ++i)
        cout << ans[i].first << ' ' << ans[i].second << endl;

    return 0;
}
0