結果

問題 No.1932 動く点 P / Moving Point P
ユーザー RhoRho
提出日時 2020-03-23 10:26:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 940 ms / 6,000 ms
コード長 2,267 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 174,676 KB
実行使用メモリ 39,988 KB
最終ジャッジ日時 2023-09-20 01:30:59
合計ジャッジ時間 24,114 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 330 ms
39,928 KB
testcase_02 AC 223 ms
39,816 KB
testcase_03 AC 393 ms
5,544 KB
testcase_04 AC 490 ms
12,192 KB
testcase_05 AC 464 ms
12,364 KB
testcase_06 AC 113 ms
21,432 KB
testcase_07 AC 940 ms
39,988 KB
testcase_08 AC 937 ms
39,892 KB
testcase_09 AC 712 ms
39,868 KB
testcase_10 AC 732 ms
39,896 KB
testcase_11 AC 724 ms
39,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define double long double
#define MRE assert(0);
const int inf = 1e17;
const double pi = 3.1415926535897932;
const int mod = 998244353;
struct matrix {
	double dat[3][3];
	matrix(){
		rep(i, 3)rep(j, 3)dat[i][j] = 0;
		rep(i, 3)dat[i][i] = 1;
	}
	void init(double theta, double p, double q) {
		theta = theta*pi / 180.0;
		dat[0][0] = cos(theta);
		dat[0][1] = -sin(theta);
		dat[0][2] = q*sin(theta) - p*cos(theta) + p;
		dat[1][0] = sin(theta);
		dat[1][1] = cos(theta);
		dat[1][2] = -p*sin(theta) - q*cos(theta) + q;
	}
};
matrix mul(matrix M2, matrix M1) {
	matrix res;
	rep(i, 3)res.dat[i][i] = 0;
	rep(i, 3) {
		rep(j, 3) {
			rep(k, 3) {
				res.dat[i][j] += M1.dat[i][k] * M2.dat[k][j];
			}
		}
	}
	return res;
}
vector<double>trans(matrix m, double x, double y) {
	vector<double>res(2);
	res[0] = m.dat[0][0] * x + m.dat[0][1] * y + m.dat[0][2];
	res[1] = m.dat[1][0] * x + m.dat[1][1] * y + m.dat[1][2];
	return res;
}
struct segtree {
	matrix ide;
	vector<matrix>node;
	int n;
	void init(int N) {
		n = 1;
		while (n < N)n *= 2;
		node.resize(2 * n);
	}
	void upd(double theta, double p, double q, int k) {
		k += n - 1;
		node[k].init(theta, p, q);
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = mul(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	matrix calc(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)return ide;
		if (a <= l&&r <= b)return node[k];
		matrix vl = calc(a, b, k * 2 + 1, l, (l + r) / 2);
		matrix vr = calc(a, b, k * 2 + 2, (l + r) / 2, r);
		return mul(vl,vr);
	}
	matrix get(int a, int b) {
		return calc(a, b, 0, 0, n);
	}
};

segtree seg;

signed main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n; cin >> n;
	seg.init(n);
	if (n > 100000)MRE;
	rep(i, n) {
		double p, q, r; cin >> p >> q >> r;
		if (abs(p) > 1000 || abs(q) > 1000)MRE;
		if (abs(r) > 360)MRE;
		seg.upd(r, p, q, i);
	}
	int q; cin >> q;
	if (q > 200000)MRE;
	rep(j, q) {
		int s, t; double x, y; cin >> s >> t >> x >> y;
		if (s > n || t > n)MRE;
		if (s < 1 || t < 1)MRE;
		if (abs(x) > 1000 || abs(y) > 1000)MRE;
		matrix M = seg.get(s - 1, t);
		vector<double>res = trans(M, x, y);
		printf("%.13Lf %.13Lf\n", res[0], res[1]);
	}
}
0