結果

問題 No.675 ドットちゃんたち
ユーザー 👑 kmjpkmjp
提出日時 2018-04-13 22:50:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 163 ms / 2,000 ms
コード長 1,489 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 146,544 KB
実行使用メモリ 11,504 KB
最終ジャッジ日時 2023-09-09 04:45:09
合計ジャッジ時間 3,964 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,464 KB
testcase_01 AC 5 ms
10,464 KB
testcase_02 AC 5 ms
10,468 KB
testcase_03 AC 5 ms
10,684 KB
testcase_04 AC 5 ms
10,468 KB
testcase_05 AC 151 ms
11,080 KB
testcase_06 AC 163 ms
11,256 KB
testcase_07 AC 144 ms
11,168 KB
testcase_08 AC 156 ms
11,300 KB
testcase_09 AC 161 ms
11,248 KB
testcase_10 AC 162 ms
11,332 KB
testcase_11 AC 160 ms
11,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll PX,PY;
int C[101010],D[101010];

const int MAT=3;
struct Mat { ll v[MAT][MAT]; Mat(){ZERO(v);v[0][0]=v[1][1]=v[2][2]=1;};}; //

Mat mulmat(Mat a,Mat b,int n=MAT) {
	int x,y,z; Mat r;
	FOR(x,n) FOR(y,n) r.v[x][y]=0;
	FOR(x,n) FOR(z,n) FOR(y,n) {
		r.v[x][y] += a.v[x][z]*b.v[z][y];
	}
	return r;
}

Mat M[101010];

Mat hoge(int c,int d) {
	Mat m;
	if(c==1) {
		m.v[0][2]=d;
	}
	if(c==2) {
		m.v[1][2]=d;
	}
	if(c==3) {
		m.v[0][0]=m.v[1][1]=0;
		m.v[0][1]=1;
		m.v[1][0]=-1;
	}
	return m;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>PX>>PY;
	FOR(i,N) {
		cin>>C[i];
		if(C[i]!=3) cin>>D[i];
	}
	
	for(i=N-1;i>=0;i--) {
		M[i]=mulmat(M[i+1],hoge(C[i],D[i]));
	}
	FOR(i,N) {
		cout<<(M[i].v[0][0]*PX+M[i].v[0][1]*PY+M[i].v[0][2])<<" "<<(M[i].v[1][0]*PX+M[i].v[1][1]*PY+M[i].v[1][2])<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0