結果

問題 No.675 ドットちゃんたち
ユーザー hato_gen_tsukihato_gen_tsuki
提出日時 2018-05-09 14:34:24
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,351 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 64,360 KB
実行使用メモリ 11,100 KB
最終ジャッジ日時 2023-09-10 11:18:49
合計ジャッジ時間 2,869 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,740 KB
testcase_01 AC 4 ms
10,740 KB
testcase_02 AC 4 ms
10,880 KB
testcase_03 AC 4 ms
10,900 KB
testcase_04 AC 5 ms
10,984 KB
testcase_05 AC 158 ms
10,756 KB
testcase_06 AC 190 ms
10,876 KB
testcase_07 WA -
testcase_08 AC 168 ms
10,744 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

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

	for(int i=0;i<NNN;i++){
		int comtemp=0;
		//command Dx
		if(command[i]>999999){
			comtemp = command[i]-1000000;

			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(command[i]==-1){
			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(command[i]>0){
			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++){
				printf("%d",matcom[i][j][k]);
			}
			printf("\n");

		}
		printf("\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++){
				printf("%d",ruicom[i][j][k]);
			}
			printf("\n");
		}
		printf("\n");
	
*/	
	}
	long int ansx=0;
	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;
		cout << ansx << " " << ansy << endl;
	}
	return 0;
}
0