結果

問題 No.1226 I hate Robot Arms
ユーザー hamamu
提出日時 2020-09-12 00:51:05
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 297 ms / 2,000 ms
コード長 10,592 bytes
コンパイル時間 2,176 ms
コンパイル使用メモリ 213,748 KB
最終ジャッジ日時 2025-01-14 12:37:20
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

·#include "bits/stdc++.h"
using namespace std;
using ll=long long;
using vll=vector< ll>;
using vvll=vector< vll>;
using vvvll=vector< vvll>;
using vvvvll=vector<vvvll>;
constexpr ll INF = 1LL << 60;
struct Fast{ //cin,cout
Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(std::numeric_limits<double>::max_digits10); }
} fast;
#define REPS(i, S, E) for (ll i = (S); i <= (E); i++)
#define REP(i, N) REPS(i, 0, (N)-1)
#define DEPS(i, S, E) for (ll i = (E); i >= (S); i--)
#define DEP(i, N) DEPS(i, 0, (N)-1)
#define rep(i, S, E) for (ll i = (S); i <= (E); i++)
#define dep(i, E, S) for (ll i = (E); i >= (S); i--)
#define each(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; }
template<class T> inline T MinE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v,0,(ll)v.size()-1); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v,0,(ll)v.size()-1); }
template<class T> inline T Sum(vector<T> &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v) { return Sum(v,0,v.size()-1); }
template<class T> inline ll sz(T &v){ return (ll)v.size(); }
template<class T> inline T POW(T a, ll n){ T r=1; for (; n>0; n>>=1, a*=a){ if (n&1)r*=a; } return r; }
inline ll POW(int a, ll n){ return POW((ll)a, n); }
inline ll CEIL(ll a, ll b){ return (a+b-1)/b; }
using dd=double;
using vdd=vector< dd>;
using vvdd=vector< vdd>;
template<class T> struct SegmentTree{
using F = function<T(T, T)>;
vector<T> dat; //i dat[i+n-1]
ll n; // 2
F f;
T ti;
SegmentTree(){}
SegmentTree(vector<T> &v, F f, T ti){ Init(v, f, ti); }
void Init(vector<T> &v, F f, T ti){
this->f=f; this->ti=ti;
for (n = 1; n < (ll)v.size(); n *= 2);
dat.resize(2*n-1, ti);
REP(i, (ll)v.size()) { dat[i+n-1] = v[i]; }//
DEP(i, n-1) { dat[i] = f(dat[2*i+1], dat[2*i+2]); }//
}
void Set(ll i, T x){ //ix
i += n-1; dat[i] = x;
while (i>0) { i=(i-1)/2; dat[i]=f(dat[2*i+1], dat[2*i+2]); }
}
T Range(ll a, ll b) { return range(a, b+1, 0, 0, n); }
T operator [] (ll i) { return dat[i+n-1]; }
void Dump(ll w=5){
REP(i, n) for (ll k=i+n-1, m=1, p=1; k>=0; p=m, m*=k%2, k=(k==0)?-1:(k-1)/2){
if (m) cerr << ((k<n-1)?"":"") << setw(w) << dat[k];
else cerr << ((p&~m) ?"":"");
if (k==0) cerr << '\n';
} cerr << '\n';
}
T range(ll a, ll b, ll k, ll l, ll r){ //k=[l,r)
if (r<=a || b<=l) return ti; //
if (a<=l && r<=b) return dat[k];//
return f(range(a, b, k*2+1, l, (l+r)/2), range(a, b, k*2+2, (l+r)/2, r));
}
ll FindL(ll a, ll b, T x) { return findL(a, b+1, x, 0, 0, n); }
ll findL(ll a, ll b, T x, ll k, ll l, ll r){ //[l,r) b
if (r<=a || b<=l || f(dat[k], x)!=dat[k]) return b; //or
if (k >= n-1) return k-(n-1); //return
ll i = findL(a, b, x, 2*k+1, l, (l+r)/2); //
if (i==b) i = findL(a, b, x, 2*k+2, (l+r)/2, r); //
return i;
}
ll FindR(ll a, ll b, T x) { return findR(a, b+1, x, 0, 0, n); }
ll findR(ll a, ll b, T x, ll k, ll l, ll r){ //[l,r) a-1
if (r<=a || b<=l || f(dat[k], x)!=dat[k]) return a-1; //or
if (k >= n-1) return k-(n-1); //return
ll i = findR(a, b, x, 2*k+2, (l+r)/2, r); //
if (i==a-1) i = findR(a, b, x, 2*k+1, l, (l+r)/2); //
return i;
}
};
//pair
using pll=pair<ll,ll>;
using vpll=vector< pll>;
using vvpll=vector<vpll>;
template<class T,class S> inline pair<T,S>& operator+=(pair<T,S> &a,const pair<T,S> &b){ a.first+=b.first; a.second+=b.second; return a; }
template<class T,class S> inline pair<T,S>& operator-=(pair<T,S> &a,const pair<T,S> &b){ a.first-=b.first; a.second-=b.second; return a; }
template<class T,class S> inline pair<T,S>& operator*=(pair<T,S> &a,const pair<T,S> &b){ a.first*=b.first; a.second*=b.second; return a; }
template<class T,class S> inline pair<T,S>& operator/=(pair<T,S> &a,const pair<T,S> &b){ a.first/=b.first; a.second/=b.second; return a; }
template<class T,class S> inline pair<T,S>& operator%=(pair<T,S> &a,const pair<T,S> &b){ a.first%=b.first; a.second%=b.second; return a; }
template<class T,class S,class R> inline pair<T,S>& operator+=(pair<T,S> &a,R b){ a.first+=b; a.second+=b; return a; }
template<class T,class S,class R> inline pair<T,S>& operator-=(pair<T,S> &a,R b){ a.first-=b; a.second-=b; return a; }
template<class T,class S,class R> inline pair<T,S>& operator*=(pair<T,S> &a,R b){ a.first*=b; a.second*=b; return a; }
template<class T,class S,class R> inline pair<T,S>& operator/=(pair<T,S> &a,R b){ a.first/=b; a.second/=b; return a; }
template<class T,class S,class R> inline pair<T,S>& operator%=(pair<T,S> &a,R b){ a.first%=b; a.second%=b; return a; }
template<class T,class S,class R> inline pair<T,S> operator+(const pair<T,S> &a,R b){ pair<T,S> c=a; return c+=b; }
template<class T,class S,class R> inline pair<T,S> operator-(const pair<T,S> &a,R b){ pair<T,S> c=a; return c-=b; }
template<class T,class S,class R> inline pair<T,S> operator*(const pair<T,S> &a,R b){ pair<T,S> c=a; return c*=b; }
template<class T,class S,class R> inline pair<T,S> operator/(const pair<T,S> &a,R b){ pair<T,S> c=a; return c/=b; }
template<class T,class S,class R> inline pair<T,S> operator%(const pair<T,S> &a,R b){ pair<T,S> c=a; return c%=b; }
template<class T,class S,class R> inline pair<T,S> operator-(R b,const pair<T,S> &a){ pair<T,S> c=-a; return c+=b; }
template<class T,class S> inline pair<T,S> operator-(const pair<T,S> &a){ pair<T,S> c=a; return c*=(-1); }
template<class T,class S> inline ostream &operator<<(ostream &os,const pair<T,S> &a){ return os << a.first << ' ' << a.second; }
//tuple3
using tll=tuple<ll,ll,ll>;
using vtll=vector< tll>;
using vvtll=vector<vtll>;
template<class T,class S,class R> inline tuple<T,S,R>& operator+=(tuple<T,S,R> &a,const tuple<T,S,R> &b){ get<0>(a)+=get<0>(b); get<1>(a)+=get<1>(b);
    get<2>(a)+=get<2>(b); return a; }
template<class T,class S,class R> inline tuple<T,S,R>& operator-=(tuple<T,S,R> &a,const tuple<T,S,R> &b){ get<0>(a)-=get<0>(b); get<1>(a)-=get<1>(b);
    get<2>(a)-=get<2>(b); return a; }
template<class T,class S,class R> inline tuple<T,S,R>& operator*=(tuple<T,S,R> &a,const tuple<T,S,R> &b){ get<0>(a)*=get<0>(b); get<1>(a)*=get<1>(b);
    get<2>(a)*=get<2>(b); return a; }
template<class T,class S,class R> inline tuple<T,S,R>& operator/=(tuple<T,S,R> &a,const tuple<T,S,R> &b){ get<0>(a)/=get<0>(b); get<1>(a)/=get<1>(b);
    get<2>(a)/=get<2>(b); return a; }
template<class T,class S,class R> inline tuple<T,S,R>& operator%=(tuple<T,S,R> &a,const tuple<T,S,R> &b){ get<0>(a)%=get<0>(b); get<1>(a)%=get<1>(b);
    get<2>(a)%=get<2>(b); return a; }
template<class T,class S,class R,class Q> inline tuple<T,S,R>& operator+=(tuple<T,S,R> &a,Q b){ get<0>(a)+=b; get<1>(a)+=b; get<2>(a)+=b; return a; }
template<class T,class S,class R,class Q> inline tuple<T,S,R>& operator-=(tuple<T,S,R> &a,Q b){ get<0>(a)-=b; get<1>(a)-=b; get<2>(a)-=b; return a; }
template<class T,class S,class R,class Q> inline tuple<T,S,R>& operator*=(tuple<T,S,R> &a,Q b){ get<0>(a)*=b; get<1>(a)*=b; get<2>(a)*=b; return a; }
template<class T,class S,class R,class Q> inline tuple<T,S,R>& operator/=(tuple<T,S,R> &a,Q b){ get<0>(a)/=b; get<1>(a)/=b; get<2>(a)/=b; return a; }
template<class T,class S,class R,class Q> inline tuple<T,S,R>& operator%=(tuple<T,S,R> &a,Q b){ get<0>(a)%=b; get<1>(a)%=b; get<2>(a)%=b; return a; }
template<class T,class S,class R,class Q> inline tuple<T,S,R> operator+(const tuple<T,S,R> &a,Q b){ tuple<T,S,R> c=a; return c+=b; }
template<class T,class S,class R,class Q> inline tuple<T,S,R> operator-(const tuple<T,S,R> &a,Q b){ tuple<T,S,R> c=a; return c-=b; }
template<class T,class S,class R,class Q> inline tuple<T,S,R> operator*(const tuple<T,S,R> &a,Q b){ tuple<T,S,R> c=a; return c*=b; }
template<class T,class S,class R,class Q> inline tuple<T,S,R> operator/(const tuple<T,S,R> &a,Q b){ tuple<T,S,R> c=a; return c/=b; }
template<class T,class S,class R,class Q> inline tuple<T,S,R> operator%(const tuple<T,S,R> &a,Q b){ tuple<T,S,R> c=a; return c%=b; }
template<class T,class S,class R,class Q> inline tuple<T,S,R> operator-(Q b,const tuple<T,S,R> &a){ tuple<T,S,R> c=-a; return c+=b; }
template<class T,class S,class R> inline tuple<T,S,R> operator-(const tuple<T,S,R> &a){ tuple<T,S,R> c=a; return c*=(-1); }
template<class T,class S,class R> inline ostream &operator<<(ostream &os,const tuple<T,S,R> &a){ return os << get<0>(a) << ' ' << get<1>(a) << ' ' <<
    get<2>(a); }
using tdd=tuple<dd,dd,dd>;
using vtdd=vector<tdd>;
void solve()
{
ll n,q; cin >> n >> q;
vdd rad(n);
vll d(n,1);
vtdd v(n,{1.,0.,0.});
SegmentTree<tdd> sgt(
v, //vector
[](tdd a, tdd b){
dd xa,ya,ta; tie(xa,ya,ta) = a;
dd xb,yb,tb; tie(xb,yb,tb) = b;
dd cosa=cos(ta);
dd sina=sin(ta);
dd xc=cosa*xb-sina*yb+xa;
dd yc=sina*xb+cosa*yb+ya;
dd tc=ta+tb;
return tdd(xc,yc,tc);
}, //
{0.,0.,0.} //
);
vector<pair<dd,dd>> ans;
rep(qq,0,q-1){
ll kind; cin >> kind;
if (kind==0){
ll i,x; cin >> i >> x;
i--;
dd rx=x*3.141592653589793238/180.;
rad[i]=rx;
sgt.Set(i,{d[i]*cos(rad[i]),d[i]*sin(rad[i]),rad[i]});
}
else if (kind==1){
ll i,x; cin >> i >> x;
i--;
d[i]=x;
sgt.Set(i,{d[i]*cos(rad[i]),d[i]*sin(rad[i]),rad[i]});
}
else{//kind==2
ll i; cin >> i; i--;
dd x,y,t; tie(x,y,t) = sgt.Range(0,i);
ans.emplace_back(x,y);
}
}
each(e,ans) cout << e << '\n';
}
int main(){
#if 1
solve();
#else
ll t; cin >> t;
rep(i, 0, t-1){
solve();
}
#endif
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0