結果

問題 No.1932 動く点 P / Moving Point P
ユーザー apricityapricity
提出日時 2023-12-02 16:14:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,466 ms / 6,000 ms
コード長 4,185 bytes
コンパイル時間 2,917 ms
コンパイル使用メモリ 152,216 KB
実行使用メモリ 76,828 KB
最終ジャッジ日時 2023-12-02 16:14:57
合計ジャッジ時間 36,083 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1,073 ms
72,104 KB
testcase_02 AC 838 ms
71,044 KB
testcase_03 AC 756 ms
8,228 KB
testcase_04 AC 1,121 ms
21,504 KB
testcase_05 AC 969 ms
21,888 KB
testcase_06 AC 414 ms
38,024 KB
testcase_07 AC 2,466 ms
76,828 KB
testcase_08 AC 2,433 ms
76,828 KB
testcase_09 AC 1,744 ms
76,828 KB
testcase_10 AC 1,743 ms
76,828 KB
testcase_11 AC 1,753 ms
76,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<utility>
#include<tuple>
#include<cstdint>
#include<cstdio>
#include<iomanip>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<cctype>
#include<chrono>
#include<random>
#include<cassert>
#include<cstddef>
#include<iterator>
#include<string_view>
#include<type_traits>

#ifdef LOCAL
#  include "debug_print.hpp"
#  define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define debug(...) (static_cast<void>(0))
#endif

using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
template<typename T> using PQ = priority_queue<T,vector<T>>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
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 (b<a) { a=b; return 1; } return 0; }
void yesno(bool flag) {cout << (flag?"Yes":"No") << "\n";}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << p.first << " " << p.second;
    return os;
}
template<typename T, typename U>
istream &operator>>(istream &is, pair<T, U> &p) {
    is >> p.first >> p.second;
    return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    int s = (int)v.size();
    for (int i = 0; i < s; i++) os << (i ? " " : "") << v[i];
    return os;
}
template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (auto &x : v) is >> x;
    return is;
}
void in() {}
template<typename T, class... U>
void in(T &t, U &...u) {
    cin >> t;
    in(u...);
}
void out() { cout << "\n"; }
template<typename T, class... U, char sep = ' '>
void out(const T &t, const U &...u) {
    cout << t;
    if (sizeof...(u)) cout << sep;
    out(u...);
}
void outr() {}
template<typename T, class... U, char sep = ' '>
void outr(const T &t, const U &...u) {
    cout << t;
    outr(u...);
}

template<typename T> struct Matrix{
    int r,c;
    vector<vector<T>> a;
    Matrix(int r, int c, T init = 0) : r(r), c(c), a(r, vector<T>(c, init)) {}
    
    Matrix& unit(){
        assert(r == c);
        rep(i,r) a[i][i] = 1;
        return *this;
    }

    const vector<T>& operator[] (int i) const {return a[i];}
    vector<T>& operator[] (int i) {return a[i];}

    Matrix operator* (const Matrix& b) const{
        assert(c == b.r);
        Matrix res(r, b.c);
        rep(i,r)rep(k,c)rep(j,b.c) res[i][j] += a[i][k] * b[k][j];
        return res;
    }

    Matrix pow(ll k) const{
        assert(r == c);
        Matrix now = *this;
        Matrix res = Matrix(r,c).unit();
        while(k){
            if(k & 1) res = res * now;
            now = now * now;
            k >>= 1;
        }
        return res;
    }
};

using mat = Matrix<D>;

#include "atcoder/segtree.hpp"

const D pi = acos(-1.0);
mat id(3,3);

mat op(mat a, mat b) {return a*b;}
mat e(){return id;}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; in(n);
    rep(i,3) id[i][i] = 1.0;
    atcoder::segtree<mat,op,e> st(n);
    rrep(i,n){
        D p,q,r; in(p,q,r);
        D co = cos(pi*r/180.0);
        D si = sin(pi*r/180.0);
        mat m(3,3);
        m[0][0] = m[1][1] = co;
        m[0][1] = -si; m[1][0] = si;
        m[2][2] = 1.0;
        m[0][2] = (1-co)*p + si*q;
        m[1][2] = (1-co)*q - si*p;
        st.set(i,m);
    }

    cout << setprecision(15);
    int q; in(q);
    while(q--){
        int s,t; D p,q; in(s,t,p,q);
        mat v(3,1);
        v[0][0] = p; v[1][0] = q; v[2][0] = 1.0;
        v = st.prod(n-t,n-s+1)*v;
        out(v[0][0], v[1][0]);
    }
}
0