結果
| 問題 |
No.1226 I hate Robot Arms
|
| コンテスト | |
| ユーザー |
carrot46
|
| 提出日時 | 2020-09-11 23:06:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,443 bytes |
| コンパイル時間 | 1,552 ms |
| コンパイル使用メモリ | 170,152 KB |
| 実行使用メモリ | 6,936 KB |
| 最終ジャッジ日時 | 2025-01-01 21:50:52 |
| 合計ジャッジ時間 | 8,443 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | WA * 28 |
ソースコード
#include <bits/stdc++.h>
//#include <chrono>
//#pragma GCC optimize("Ofast")
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll N,M,H,W,Q,K,A,B;
string S;
typedef pair<ll, ll> P;
const ll INF = (1LL<<60);
template <unsigned long long mod > class modint{
public:
ll x;
modint(){x = 0;}
modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){}
modint operator-(){
return x == 0 ? 0 : mod - x;
}
modint& operator+=(const modint& a){
if((x += a.x) >= mod) x -= mod;
return *this;
}
modint operator+(const modint& a) const{
return modint(*this) += a;
}
modint& operator-=(const modint& a){
if((x -= a.x) < 0) x += mod;
return *this;
}
modint operator-(const modint& a) const{
return modint(*this) -= a;
}
modint& operator*=(const modint& a){
(x *= a.x)%=mod;
return *this;
}
modint operator*(const modint& a) const{
return modint(*this) *= a;
}
modint pow(unsigned long long pw) const{
modint res(1), comp(*this);
while(pw){
if(pw&1) res *= comp;
comp *= comp;
pw >>= 1;
}
return res;
}
//以下、modが素数のときのみ
modint inv() const{
return modint(*this).pow(mod - 2);
}
modint& operator/=(const modint &a){
(x *= a.inv().x)%=mod;
return *this;
}
modint operator/(const modint &a) const{
return modint(*this) /= a;
}
};
using mint = modint<360>;
ostream& operator<<(ostream& os, const mint& a){
os << a.x;
return os;
}
using vm = vector<mint>;
using Pd = pair<double, double>;
vector<double> my_cos(360), my_sin(360);
struct arm{
//groupではlazy, elemでは真値
mint theta;
double len; //elemのみ
Pd v;
arm() : theta(0), len(1), v(1, 0) {}
arm(int l) : theta(0), len(l) {v = make_pair(l, 0);}
void set_v(){
v = make_pair(my_cos[theta.x] * len, my_sin[theta.x] * len);
}
arm &operator += (const arm &a){
v.fi += a.v.fi;
v.se += a.v.se;
return *this;
}
const arm operator + (const arm &a){
return arm(*this) += a;
}
};
int main() {
cin>>N>>Q;
const int sz = 317, num = 317;
vector<arm> group(num, arm(sz)), elem(num * sz, arm());
const long double pi = acos(-1);
rep(i, 360){
long double phi = pi * i / 180;
my_cos[i] = cos(phi);
my_sin[i] = sin(phi);
}
rep(_, Q){
int i, x, id;
cin>>A>>i; --i;
id = i / sz;
if(A == 1){
cin>>x;
if(group[id].theta.x != 0){
reps(j, id * sz, (id + 1) * sz) {
elem[j].theta += group[id].theta;
elem[j].set_v();
}
}
elem[i].len = x;
elem[i].set_v();
group[id] = accumulate(elem.begin() + id * sz, elem.begin() + (id + 1) * sz, arm(0));
group[id].theta = 0;
}else if(A == 0){
cin>>x;
reps(j, id * sz, (id + 1) * sz) {
elem[j].theta += group[id].theta;
if(j >= i) elem[j].theta += x;
elem[j].set_v();
}
group[id] = accumulate(elem.begin() + id * sz, elem.begin() + (id + 1) * sz, arm(0));
group[id].theta = 0;
reps(j, id + 1, num) group[j].theta += x;
}else{
Pd res(0, 0);
rep(j, id) {
int temp = group[j].theta.x;
Pd &p = group[j].v;
res.fi += p.fi * my_cos[temp] - p.se * my_sin[temp];
res.se += p.fi * my_sin[temp] + p.se * my_cos[temp];
}
reps(j, id * sz, (id + 1) * sz) {
elem[j].theta += group[id].theta;
elem[j].set_v();
if(j <= i) {
res.fi += elem[j].v.fi;
res.se += elem[j].v.se;
}
}
cout<<fixed<<setprecision(10)<<res.fi<<' '<<res.se<<endl;
}
}
}
carrot46