結果
| 問題 |
No.675 ドットちゃんたち
|
| コンテスト | |
| ユーザー |
ikd
|
| 提出日時 | 2018-04-16 18:47:05 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
AC
|
| 実行時間 | 246 ms / 2,000 ms |
| コード長 | 1,324 bytes |
| コンパイル時間 | 1,410 ms |
| コンパイル使用メモリ | 143,340 KB |
| 実行使用メモリ | 38,912 KB |
| 最終ジャッジ日時 | 2024-06-13 00:30:11 |
| 合計ジャッジ時間 | 4,393 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 8 |
ソースコード
void main(){
import std.stdio, std.string, std.conv, std.algorithm;
int n;
long px, py; rd(n, px, py);
int m=3;
auto mats=new long[][][](n, m, m);
foreach(i; 0..n){
auto args=readln.split.to!(int[]);
if(args[0]==1){
mats[i][0][0]=mats[i][1][1]=mats[i][2][2]=1;
mats[i][0][2]=args[1];
}else if(args[0]==2){
mats[i][0][0]=mats[i][1][1]=mats[i][2][2]=1;
mats[i][1][2]=args[1];
}else if(args[0]==3){
mats[i][0][1]=1;
mats[i][1][0]=-1;
mats[i][2][2]=1;
}
}
auto T=new long[][](m, m);
T[0][0]=T[1][1]=T[2][2]=1;
long[] v=[px, py, 1L];
struct Point{
long x, y;
string toString(){
return x.to!(string)~" "~y.to!(string);
}
}
auto points=new Point[](n);
foreach_reverse(idx, mat; mats){
auto U=new long[][](m, m);
foreach(i; 0..m)foreach(j; 0..m){
long tmp=0;
foreach(k; 0..m) tmp+=T[i][k]*mat[k][j];
U[i][j]=tmp;
}
T.swap(U);
long qx=0, qy=0;
foreach(k; 0..m){
qx+=T[0][k]*v[k];
qy+=T[1][k]*v[k];
}
points[idx]=Point(qx, qy);
// writeln(qx, " ", qy);
}
writefln("%(%s\n%)", points);
}
void rd(T...)(ref T x){
import std.stdio, std.string, std.conv;
auto l=readln.split;
assert(l.length==x.length);
foreach(i, ref e; x) e=l[i].to!(typeof(e));
}
ikd