結果

問題 No.1932 動く点 P / Moving Point P
ユーザー woodywoodywoodywoody
提出日時 2022-05-15 17:57:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,868 ms / 6,000 ms
コード長 4,703 bytes
コンパイル時間 4,337 ms
コンパイル使用メモリ 245,320 KB
実行使用メモリ 122,540 KB
最終ジャッジ日時 2024-09-13 03:09:23
合計ジャッジ時間 39,248 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 954 ms
93,056 KB
testcase_02 AC 778 ms
86,528 KB
testcase_03 AC 580 ms
15,076 KB
testcase_04 AC 787 ms
34,432 KB
testcase_05 AC 881 ms
36,760 KB
testcase_06 AC 431 ms
49,920 KB
testcase_07 AC 1,832 ms
122,492 KB
testcase_08 AC 1,868 ms
122,540 KB
testcase_09 AC 1,723 ms
122,528 KB
testcase_10 AC 1,745 ms
122,480 KB
testcase_11 AC 1,774 ms
122,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,b) for(int i=0;i<b;i++)
#define rrep(i,b) for(int i=b-1;i>=0;i--)
#define rep1(i,b) for(int i=1;i<b;i++)
#define repx(i,x,b) for(int i=x;i<b;i++)
#define fore(i,a) for(auto i:a)
#define fore1(i,a) for(auto &i:a)
#define rng(x) (x).begin(), (x).end()
#define rrng(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define fi first
#define se second

using namespace std;
using namespace atcoder;

using ll = long long;
template<typename T> using mpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<typename T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> ll sumv(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}
bool yn(bool a) { if(a) {cout << "Yes" << endl; return 1;} else {cout << "No" << endl; return 0;}}
#define dame { cout << "No" << endl; return 0;}
#define dame1 { cout << -1 << endl; return 0;}
#define test(x) cout << "test" << x << endl;
#define deb(x,y) cout << x << " " << y << endl;
#define out cout << ans << endl;
#define outv fore(yans , ans) cout << yans << endl;
#define show(x) cerr<<#x<<" = "<<x<<endl;
#define showv(v) {fore(vy , v) {cout << vy << " ";} cout << endl;}
#define showv2(v) fore(vy , v) cout << vy << endl;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pii = pair<int,int>;
using tp = tuple<int ,int ,int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;
using vpil = vector<pil>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
using vvpii = vector<vector<pii>>;
using vvpli = vector<vector<pli>>;
using vvpll = vector<vpll>;
using vvpil = vector<vpil>;
using mint = modint998244353;
using vm = vector<mint>;
using vvm = vector<vector<mint>>;
vector<int> dx={1,0,-1,0,1,1,-1,-1},dy={0,1,0,-1,1,-1,1,-1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

struct mat{
    vector<vector<long double>> v;

    mat(long double a=1,long double b=0,long double c=0,long double d=0,long double e=1,long double f=0,long double g=0
    ,long double h=0,long double i=1) {
        v.resize(3,vector<long double>(3));

        v[0][0] = a;
        v[0][1] = b;
        v[0][2] = c;
        v[1][0] = d;
        v[1][1] = e;
        v[1][2] = f;
        v[2][0] = g;
        v[2][1] = h;
        v[2][2] = i;
    }

    mat operator*(const mat& ot) {
        mat ret;
        rep(i,3) rep(j,3){
            ret.v[i][j] = 0;
            rep(k,3) ret.v[i][j] += v[i][k]*ot.v[k][j];
        }

        return ret;
    }
};

int main(){
    int n; cin>>n;

    vector<mat> a(n),ar(n);
    vector<mat> sum(n),sumr(n);

    rep(i,n){
        long double p,q,r; cin>>p>>q>>r;

        long double theta = (long double)r/180*M_PI;

        long double co=cosl(theta),si=sinl(theta);

        show(i);

        // cout << fixed << setprecision(8) << theta << endl;

        a[i].v[0][0] = co;
        a[i].v[0][1] = -si;
        a[i].v[0][2] = (-co+1)*p + si*q;
        a[i].v[1][0] = si;
        a[i].v[1][1] = co;
        a[i].v[1][2] = -si*p + (-co+1)*q;
        a[i].v[2][0] = 0;
        a[i].v[2][1] = 0;
        a[i].v[2][2] = 1;

        theta *= -1;

        co=cosl(theta),si=sinl(theta);

        ar[i].v[0][0] = co;
        ar[i].v[0][1] = -si;
        ar[i].v[0][2] = (-co+1)*p + si*q;
        ar[i].v[1][0] = si;
        ar[i].v[1][1] = co;
        ar[i].v[1][2] = -si*p + (-co+1)*q;
        ar[i].v[2][0] = 0;
        ar[i].v[2][1] = 0;
        ar[i].v[2][2] = 1;

        if (i == 0){
            sum[i] = a[i]*sum[i];
            sumr[i] = sumr[i]*ar[i];
        }else{
            sum[i] = a[i]*sum[i-1];
            sumr[i] = sumr[i-1]*ar[i];
        }
        // show(i);

        // cout << fixed << setprecision(8) <<  a[i].v[0][0] << endl;
    }


    int q; cin>>q;

    vector<pair<long double , long double>> ans(q);

    rep(i,q){
        int s,t; cin>>s>>t;
        s--; t--;
        long double x,y; cin>>x>>y;

        mat v = sum[t];
        if (s != 0) v = v*sumr[s-1];


        ans[i].fi = v.v[0][0]*x + v.v[0][1]*y + v.v[0][2];
        ans[i].se = v.v[1][0]*x + v.v[1][1]*y + v.v[1][2];
    }

    rep(i,q){
        cout << fixed << setprecision(20) << ans[i].fi << " " << ans[i].se << endl;
    }

    

    return 0;
}
0