結果

問題 No.760 Where am I moved to?
ユーザー parukiparuki
提出日時 2018-12-22 08:07:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
J_TLE  
(最初)
実行時間 -
コード長 2,012 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 174,148 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-26 02:01:06
合計ジャッジ時間 11,267 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

const double EPS = 1e-9;
using Vec = vector<double>;
using Matrix = vector<Vec>;
Vec GaussJordan(Matrix &A) {
    int n = (int)A.size();
    for (int i = 0; i < n; ++i) {
        int pivot = i;
        for (int j = i + 1; j < n; ++j)
            if (abs(A[j][i])>abs(A[pivot][i])) pivot = j;
        swap(A[i], A[pivot]);
        if (abs(A[i][i]) < EPS && abs(A[i][n]) > EPS)
            return Vec();
        for (int j = n; j >= i; --j)A[i][j] /= A[i][i];
        for (int j = 0; j < n; ++j)if (j != i)
            for (int k = n; k >= i; --k)A[j][k] -= A[i][k] * A[j][i];
    }
    Vec res(n);
    for (int i = 0; i < n; ++i)res[i] = A[i][n];
    return res;
}

void solve() {
    double xa, ya, ta, x[2][2], y[2][2], co, si;
    cin >> xa >> ya >> ta;
    rep(i, 2)rep(j, 2)cin >> x[i][j] >> y[i][j];

    double xx = x[0][0] - x[0][1], yy = y[0][0] - y[0][1];
    double XX = x[1][0] - x[1][1], YY = y[1][0] - y[1][1];

    Matrix A(2, Vec(3));
    A[0][0] = A[1][1] = xx;
    A[0][1] = -yy;
    A[1][0] = yy;
    A[0][2] = XX;
    A[1][2] = YY;
    auto gd = GaussJordan(A);
    co = gd[0], si = gd[1];

    double p = x[1][0] - x[0][0] * co + y[0][0] * si;
    double q = y[1][0] - x[0][0] * si - y[0][0] * co;
    double t = ta + acos(co) / M_PI * 180;

    cout << xa - p << ' ' << ya - q << ' ' << t << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}
0