結果

問題 No.675 ドットちゃんたち
ユーザー kotatsugamekotatsugame
提出日時 2020-03-05 11:49:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 460 ms
コンパイル使用メモリ 65,324 KB
実行使用メモリ 12,160 KB
最終ジャッジ日時 2024-04-22 02:13:59
合計ジャッジ時間 3,125 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 148 ms
12,160 KB
testcase_06 AC 172 ms
12,160 KB
testcase_07 AC 148 ms
11,392 KB
testcase_08 AC 154 ms
12,160 KB
testcase_09 AC 162 ms
12,160 KB
testcase_10 AC 173 ms
12,032 KB
testcase_11 AC 163 ms
12,160 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
long Px,Py;
struct Mat{long A[3][3];}E,Q[1<<17];
Mat Mmul(Mat a,Mat b)
{
	Mat ret;
	for(int i=0;i<3;i++)for(int j=0;j<3;j++)
	{
		ret.A[i][j]=0;
		for(int k=0;k<3;k++)ret.A[i][j]+=a.A[i][k]*b.A[k][j];
	}
	return ret;
}
long ax[1<<17],ay[1<<17];
main()
{
	cin>>N>>Px>>Py;
	for(int i=0;i<3;i++)E.A[i][i]=1;
	for(int i=0;i<N;i++)
	{
		int id;cin>>id;
		if(id==1)
		{
			long d;cin>>d;
			Q[i]=E;
			Q[i].A[0][2]=d;
		}
		else if(id==2)
		{
			long d;cin>>d;
			Q[i]=E;
			Q[i].A[1][2]=d;
		}
		else
		{
			Q[i].A[0][1]=Q[i].A[2][2]=1;
			Q[i].A[1][0]=-1;
		}
	}
	for(int i=N;i--;)
	{
		E=Mmul(E,Q[i]);
		ax[i]=E.A[0][0]*Px+E.A[0][1]*Py+E.A[0][2];
		ay[i]=E.A[1][0]*Px+E.A[1][1]*Py+E.A[1][2];
	}
	for(int i=0;i<N;i++)cout<<ax[i]<<" "<<ay[i]<<endl;
}
0