結果

問題 No.675 ドットちゃんたち
ユーザー hato_gen_tsukihato_gen_tsuki
提出日時 2018-05-09 14:47:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 2,540 bytes
コンパイル時間 462 ms
コンパイル使用メモリ 64,128 KB
実行使用メモリ 18,976 KB
最終ジャッジ日時 2023-09-10 11:19:19
合計ジャッジ時間 2,186 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
18,844 KB
testcase_01 AC 6 ms
18,704 KB
testcase_02 AC 5 ms
18,708 KB
testcase_03 AC 6 ms
18,700 KB
testcase_04 AC 6 ms
18,680 KB
testcase_05 AC 38 ms
18,908 KB
testcase_06 AC 66 ms
18,924 KB
testcase_07 AC 51 ms
18,848 KB
testcase_08 AC 47 ms
18,756 KB
testcase_09 AC 56 ms
18,712 KB
testcase_10 AC 64 ms
18,680 KB
testcase_11 AC 53 ms
18,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <stdio.h>

using namespace std;

int main (){
	long long int NNN,PX,PY;
	cin >> NNN >> PX >> PY;
	long int command[100000]={0};
	int check[100000]={0};
	long long int temp;
	for(int i =0;i<NNN;i++){
		cin >> temp;
		if(temp==1){
			check[i]=temp;
			cin >> temp;
			command[i]=temp;
			temp=0;
		}
		if(temp==2){
			check[i]=temp;
			cin >> temp ;
			command[i]=temp;
			temp=0;
		}
		if(temp==3){
			check[i]=temp;
			command[i]=-1;
		}
	}
	long long int matcom[100000][3][3]={0}; //各コマンドを行列化して格納する
	long long int ruicom[100000][3][3]={0}; //行列の積を格納する
	long long int comtemp=0;
	for(int i=0;i<NNN;i++){
		comtemp=0;	
		//command Dx
		if(check[i]==1){
			comtemp = command[i];

			for(int j=0;j<3;j++){
				for(int k=0;k<3;k++){
					if(j==k){
						matcom[i][j][k]=1;
					}
					else{
						matcom[i][j][k]=0;
					}

				}
			}

			matcom[i][0][2]=comtemp;
		}

		//command 90deg
		else if(check[i]==3){
			matcom[i][0][0]=0;
			matcom[i][0][1]=1;
			matcom[i][0][2]=0;
			matcom[i][1][0]=-1;
			matcom[i][1][1]=0;
			matcom[i][1][2]=0;
			matcom[i][2][0]=0;
			matcom[i][2][1]=0;
			matcom[i][2][2]=1;
		}

		//command Dy
		else if(check[i]==2){
			for(int j=0;j<3;j++){
				for(int k=0;k<3;k++){
					if(j==k){
						matcom[i][j][k]=1;
					}
					else{
						matcom[i][j][k]=0;
					}

				}
			}
			matcom[i][1][2]=command[i];
		}
		/*
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				prlong long intf("%d",matcom[i][j][k]);
			}
			prlong long intf("\n");

		}
		prlong long intf("\n");
		*/

		

	}




	for(int i =NNN-1;i>-1;i--){
		//i=0は、なにもかけなくていいです
		if(i==NNN-1){
			for(int j=0;j<3;j++){
				for(int k=0;k<3;k++){
					ruicom[i][j][k]=matcom[i][j][k];
				}
			}
		}
		else {
			for(int j=0;j<3;j++){
				for(int k=0;k<3;k++){
					ruicom[i][j][k]=0;
					for(int l=0;l<3;l++){
						ruicom[i][j][k] += ruicom[i+1][j][l]*matcom[i][l][k];
					}
				}
			}			
		}
/*
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				prlong long intf("%d",ruicom[i][j][k]);
			}
			prlong long intf("\n");
		}
		prlong long intf("\n");
	
*/	
	}
	long long int ansx=0;
	long long int ansy=0;
	for(int i=NNN-1;i>-1;i--){
		ansx = ruicom[NNN-1-i][0][0] * PX + ruicom[NNN-1-i][0][1]* PY + ruicom[NNN-1-i][0][2] * 1;
		ansy = ruicom[NNN-1-i][1][0] * PX + ruicom[NNN-1-i][1][1]* PY + ruicom[NNN-1-i][1][2] * 1;

		printf("%lld %lld\n",ansx,ansy);
	}

	return 0;
}
0