結果

問題 No.675 ドットちゃんたち
ユーザー 夕叢霧香(ゆうむらきりか)夕叢霧香(ゆうむらきりか)
提出日時 2018-04-13 22:45:58
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 251 ms / 2,000 ms
コード長 1,248 bytes
コンパイル時間 1,154 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 24,224 KB
最終ジャッジ日時 2023-09-09 04:42:58
合計ジャッジ時間 4,541 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 216 ms
24,216 KB
testcase_06 AC 251 ms
24,140 KB
testcase_07 AC 213 ms
21,956 KB
testcase_08 AC 229 ms
24,224 KB
testcase_09 AC 238 ms
24,104 KB
testcase_10 AC 245 ms
24,100 KB
testcase_11 AC 236 ms
24,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
typedef long long lint;
typedef vector<int>vi;
typedef pair<int,int>pii;
#define rep(i,n)for(int i=0;i<(int)(n);++i)
typedef vector<lint> vl;

vector<vl> mul(const vector<vl> &a,const vector<vl> &b){
  int n=a.size();
  vector<vl> ret(n,vl(n));
  rep(i,n)rep(j,n)rep(k,n){
    ret[i][j]=ret[i][j]+a[i][k]*b[k][j];
  }
  return ret;
}

int main(){
  int n;
  lint px,py;
  cin>>n>>px>>py;
  vector<vector<vl> > ops(n);
  rep(i,n){
    int ty;
    cin>>ty;
    vector<vl> t(3,vl(3));
    t[2][2]=1;
    if(ty==1){
      lint v;
      cin>>v;
      t[0][2]=v;
      t[0][0]=t[1][1]=1;
    }else if(ty==2){
      lint v;
      cin>>v;
      t[1][2]=v;
      t[0][0]=t[1][1]=1;
    }else{
      t[1][0]=-1;
      t[0][1]=1;
    }
    ops[i]=t;
  }
  vector<vl> acc(3,vl(3));
  vl init(3);
  init[0]=px;
  init[1]=py;
  init[2]=1;
  rep(i,3)acc[i][i]=1;
  vl ax(n),ay(n);
  for(int i=n-1;i>=0;--i){
    acc=mul(acc,ops[i]);
    lint x=0,y=0;
    rep(j,3){
      x+=acc[0][j]*init[j];
      y+=acc[1][j]*init[j];
    }
    ax[i]=x;
    ay[i]=y;
    if(0){
      rep(a,3){
	rep(b,3)cerr<<" "<<acc[a][b];
	cerr<<endl;
      }
    }
  }
  rep(i,n)cout<<ax[i]<<" "<<ay[i]<<endl;

}
0