結果

問題 No.1932 動く点 P / Moving Point P
ユーザー kabipoyokabipoyo
提出日時 2022-05-06 23:57:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,155 ms / 6,000 ms
コード長 2,852 bytes
コンパイル時間 4,627 ms
コンパイル使用メモリ 269,188 KB
実行使用メモリ 45,556 KB
最終ジャッジ日時 2023-09-20 07:38:40
合計ジャッジ時間 29,299 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 426 ms
35,764 KB
testcase_02 AC 299 ms
32,952 KB
testcase_03 AC 513 ms
6,616 KB
testcase_04 AC 628 ms
13,688 KB
testcase_05 AC 699 ms
14,320 KB
testcase_06 AC 157 ms
20,148 KB
testcase_07 AC 1,155 ms
45,556 KB
testcase_08 AC 1,148 ms
45,044 KB
testcase_09 AC 1,026 ms
45,092 KB
testcase_10 AC 1,059 ms
45,396 KB
testcase_11 AC 1,049 ms
44,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<double>;
using vvi = vector<vector<double>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;
constexpr double PI=3.14159265358979323846;
#define deg_to_rad(deg) (((deg)/360)*2*PI)
#define rad_to_deg(rad) (((rad)/2/PI)*360)
vvi matrix_mul(vvi A, vvi B) {
	vvi C(A.size(), vi(B[0].size()));
	rep(i, A.size()) {
		rep(k, B.size()) {
			rep(j, B[0].size()) {
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}
	return C;
}

int main() {
	lint N, Q;
	cin >> N;
	vi p(N), q(N), r(N);
	rep(i, N) cin >> p[i] >> q[i] >> r[i];

	lint a=0, b=0, c=0;
	double x, y, z;
	std::vector<vvi> v, w;
	vvi e(3, vi(3));
	e[0][0] = 1;
	e[1][1] = 1;
	e[2][2] = 1;
	v.pb(e);
	w.pb(e);
	rep(i, N) {
		vvi t(3, vi(3));
		x = sin(deg_to_rad(r[i]));
		y = cos(deg_to_rad(r[i]));
		t[0][0] = y;
		t[0][1] = -x;
		t[0][2] = p[i]-p[i]*y+q[i]*x;
		t[1][0] = x;
		t[1][1] = y;
		t[1][2] = q[i]-p[i]*x-q[i]*y;
		t[2][2] = 1;
		v.pb(t);
		x = sin(deg_to_rad(-r[i]));
		y = cos(deg_to_rad(-r[i]));
		t[0][0] = y;
		t[0][1] = -x;
		t[0][2] = p[i]-p[i]*y+q[i]*x;
		t[1][0] = x;
		t[1][1] = y;
		t[1][2] = q[i]-p[i]*x-q[i]*y;
		t[2][2] = 1;
		w.pb(t);
	}
	// cout << fixed << setprecision(10);
	// rep(i, N) {
	// 	rep(j, 3) {
	// 		rep(k, 3) {
	// 			std::cout << v[i][j][k] << ' ';
	// 		}
	// 		std::cout << '\n';
	// 	}
	// 	std::cout << '\n';
	// }
	rep(i, N) {
		v[i+1] = matrix_mul(v[i+1], v[i]);
		w[i+1] = matrix_mul(w[i], w[i+1]);
	}

	cin >> Q;
	rep(_, Q) {
		cin >> a >> b >> x >> y;
		a--;
		vvi t(3, vi(1));
		t[0][0] = x;
		t[1][0] = y;
		t[2][0] = 1;
		// t = matrix_mul(w[a], t);
		// cout << fixed << setprecision(10) << t[0][0] << ' ' << t[1][0] << endl;
		// t = matrix_mul(v[b], t);
		// cout << fixed << setprecision(10) << t[0][0] << ' ' << t[1][0] << endl;
		// std::cout << '\n';
		t = matrix_mul(matrix_mul(v[b], w[a]), t);
		cout << fixed << setprecision(10) << t[0][0] << ' ' << t[1][0] << endl;
	}
	// rep(i, N) {
	// 	rep(j, 3) {
	// 		rep(k, 3) {
	// 			std::cout << v[i][j][k] << ' ';
	// 		}
	// 		std::cout << '\n';
	// 	}
	// 	std::cout << '\n';
	// }
}
0