結果

問題 No.1932 動く点 P / Moving Point P
ユーザー 👑 kmjpkmjp
提出日時 2022-05-06 22:46:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 720 ms / 6,000 ms
コード長 2,210 bytes
コンパイル時間 2,322 ms
コンパイル使用メモリ 204,264 KB
実行使用メモリ 42,660 KB
最終ジャッジ日時 2023-09-20 03:53:14
合計ジャッジ時間 23,384 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
39,616 KB
testcase_01 AC 238 ms
42,164 KB
testcase_02 AC 153 ms
42,092 KB
testcase_03 AC 328 ms
40,356 KB
testcase_04 AC 391 ms
40,616 KB
testcase_05 AC 404 ms
40,956 KB
testcase_06 AC 85 ms
41,304 KB
testcase_07 AC 720 ms
42,552 KB
testcase_08 AC 718 ms
42,620 KB
testcase_09 AC 557 ms
42,660 KB
testcase_10 AC 574 ms
42,600 KB
testcase_11 AC 569 ms
42,532 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#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 FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------


const int MAT=3;
struct Mat { double 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;
}

template<class V,int NV> class SegTree_1 {
public:
	vector<V> val;
	V comp(V l,V r){ return mulmat(r,l);};
	
	SegTree_1(){val=vector<V>(NV*2,Mat());};
	V getval(int x,int y,int l=0,int r=NV,int k=1) { // x<=i<y
		if(r<=x || y<=l) return Mat();
		if(x<=l && r<=y) return val[k];
		return comp(getval(x,y,l,(l+r)/2,k*2),getval(x,y,(l+r)/2,r,k*2+1));
	}
	void update(int entry, V v) {
		entry += NV;
		val[entry]=v; //上書きかチェック
		while(entry>1) entry>>=1, val[entry]=comp(val[entry*2],val[entry*2+1]);
	}
};
SegTree_1<Mat,1<<18> st;

int N,T;
double P[101010],Q[101010],R[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	double PI=atan(1)*4;
	
	cin>>N;
	FOR(i,N) {
		cin>>P[i]>>Q[i]>>R[i];
		Mat m;
		double c=cos(R[i]*PI/180);
		double s=sin(R[i]*PI/180);
		m.v[0][0]=m.v[1][1]=c;
		m.v[0][1]=-s;
		m.v[1][0]=s;
		m.v[0][2]=P[i]*(1-c)+Q[i]*s;
		m.v[1][2]=Q[i]*(1-c)-P[i]*s;
		st.update(i,m);
	}
	
	cin>>T;
	while(T--) {
		int S,T;
		double X,Y;
		cin>>S>>T>>X>>Y;
		Mat m=st.getval(S-1,T);
		double dx=m.v[0][0]*X+m.v[0][1]*Y+m.v[0][2];
		double dy=m.v[1][0]*X+m.v[1][1]*Y+m.v[1][2];
		_P("%.12lf %.12lf\n",dx,dy);
	}
	
	
}


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