結果
| 問題 | No.675 ドットちゃんたち | 
| コンテスト | |
| ユーザー |  どらら | 
| 提出日時 | 2018-04-16 20:54:49 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 242 ms / 2,000 ms | 
| コード長 | 1,680 bytes | 
| コンパイル時間 | 1,934 ms | 
| コンパイル使用メモリ | 181,024 KB | 
| 実行使用メモリ | 14,796 KB | 
| 最終ジャッジ日時 | 2024-06-27 04:03:49 | 
| 合計ジャッジ時間 | 5,304 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 8 | 
ソースコード
#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;
}
            
            
            
        