結果

問題 No.675 ドットちゃんたち
ユーザー どららどらら
提出日時 2018-04-16 20:54:49
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 242 ms / 2,000 ms
コード長 1,680 bytes
コンパイル時間 1,942 ms
コンパイル使用メモリ 179,756 KB
実行使用メモリ 14,940 KB
最終ジャッジ日時 2023-09-09 10:56:04
合計ジャッジ時間 5,018 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 208 ms
14,428 KB
testcase_06 AC 242 ms
14,940 KB
testcase_07 AC 214 ms
13,760 KB
testcase_08 AC 223 ms
14,700 KB
testcase_09 AC 230 ms
14,508 KB
testcase_10 AC 241 ms
14,764 KB
testcase_11 AC 226 ms
14,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

typedef vector<ll> vec;
typedef vector<vec> mat;
mat mul(mat &A, mat &B){
  mat C(A.size(), vec(B[0].size()));
  rep(i,A.size()) rep(k,B.size()){
    rep(j,B[0].size()){
      C[i][j] = (C[i][j]+A[i][k]*B[k][j]);
    }
  }
  return C;
}
vector<ll> mulv(mat &A, vector<ll> v){
  vector<ll> ret = v;
  rep(i,v.size()){
    ll res = 0;
    rep(j,v.size()){
      res += A[i][j]*v[j];
    }
    ret[i] = res;
  }
  return ret;
}



int main(){
  int N;
  ll Px, Py;
  cin >> N >> Px >> Py;
  vector<vector<ll>> commands;
  rep(i,N){
    ll type;
    cin >> type;
    if(type == 1){
      ll Dx;
      cin >> Dx;
      commands.push_back({1,Dx});
    }
    else if(type == 2){
      ll Dy;
      cin >> Dy;
      commands.push_back({2,Dy});
    }
    else {
      commands.push_back({3,-1});
    }
  }

  mat P = {{1,0,0},{0,1,0},{0,0,1}};
  
  vector<vector<ll>> pos;
  for(int i=commands.size()-1; i>=0; i--){
    mat X;
    if(commands[i][0] == 1){
      X = {{1,0,commands[i][1]},{0,1,0},{0,0,1}};
    }
    else if(commands[i][0] == 2){
      X = {{1,0,0},{0,1,commands[i][1]},{0,0,1}};
    }
    else{
      X = {{0,1,0},{-1,0,0},{0,0,1}};
    }

    P = mul(P, X);

    vec st = {Px, Py, 1};
    vec ret = mulv(P, st);
    pos.push_back({ret[0],ret[1]});
  }

  reverse(ALLOF(pos));

  rep(i,pos.size()){
    cout << pos[i][0] << " " << pos[i][1] << endl;
  }
  
  return 0;
}
0