結果
| 問題 |
No.675 ドットちゃんたち
|
| コンテスト | |
| ユーザー |
482ET
|
| 提出日時 | 2018-06-18 21:24:50 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 269 ms / 2,000 ms |
| コード長 | 1,737 bytes |
| コンパイル時間 | 2,162 ms |
| コンパイル使用メモリ | 172,276 KB |
| 実行使用メモリ | 22,784 KB |
| 最終ジャッジ日時 | 2024-06-30 17:04:08 |
| 合計ジャッジ時間 | 4,560 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define X real()
#define Y imag()
using namespace std;
using ll = long long;
using P = complex<double>;
using L = pair<P,P>;
using MT = vector<vector<ll>>;
const double EPS=1e-9;
// 内積 dot(a,b) = |a||b|cosθ
double dot(P a, P b) {
return (conj(a)*b).X;
}
// 外積 cross(a,b) = |a||b|sinθ
double cross(P a, P b) {
return (conj(a)*b).Y;
}
// 直線と線分
bool isecLS(P a1, P a2, P b1, P b2) {
return cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS;
}
MT mul(MT a, MT b){
MT c(3,vector<ll>(3,0));
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
int tmp=0;
for(int k=0;k<3;k++){
tmp+=a[i][k]*b[k][j];
}
c[i][j]=tmp;
}
}
return c;
}
int main(){
ll n;
vector<ll> p(3,1);
cin>>n>>p[0]>>p[1];
vector<MT> vc(n,MT(3,vector<ll>(3,0)));
int b;
for(int i=0;i<n;i++){
cin>>b;
switch(b){
case 1:
cin>>b;
vc[i]=MT{{1,0,b},{0,1,0},{0,0,1}};
break;
case 2:
cin>>b;
vc[i]=MT{{1,0,0},{0,1,b},{0,0,1}};
break;
case 3:
vc[i]=MT{{0,1,0},{-1,0,0},{0,0,1}};
break;
default:
break;
}
}
for(int i=n-1;i>=1;i--){
vc[i-1]=mul(vc[i],vc[i-1]);
}
for(int i=0;i<n;i++){
int tmp=0;
for(int j=0;j<3;j++){
tmp+=vc[i][0][j]*p[j];
}
cout<<tmp<<" ";
tmp=0;
for(int j=0;j<3;j++){
tmp+=vc[i][1][j]*p[j];
}
cout<<tmp<<endl;
}
}
482ET