結果
問題 | No.675 ドットちゃんたち |
ユーザー | ふっぴー |
提出日時 | 2018-04-14 00:49:56 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,914 bytes |
コンパイル時間 | 1,967 ms |
コンパイル使用メモリ | 179,892 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-26 22:03:24 |
合計ジャッジ時間 | 4,452 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,248 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 193 ms
6,528 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 207 ms
6,528 KB |
testcase_09 | AC | 219 ms
6,528 KB |
testcase_10 | AC | 227 ms
6,400 KB |
testcase_11 | WA | - |
ソースコード
#include "bits/stdc++.h" using namespace std; #define DEBUG(x) cout<<#x<<": "<<x<<endl; #define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl typedef long long ll; #define vi vector<int> #define vl vector<ll> #define vii vector< vector<int> > #define vll vector< vector<ll> > #define vs vector<string> #define pii pair<int,int> #define pis pair<int,string> #define psi pair<string,int> #define pll pair<ll,ll> #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)(n);i++) #define rep1(i,n) for(int i=1;i<=(int)(n);i++) #define all(c) c.begin(),c.end() const int inf = 1000000001; const ll INF = 2e18; const ll MOD = 1000000007; //const ll mod = 1000000009; const double pi = 3.14159265358979323846; #define Sp(p) cout<<setprecision(15)<< fixed<<p;//<<endl; int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 }; int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 }; struct Modint { ll n; static const ll Mod = 1000000007; Modint(int n = 0) : n(n) {} }; Modint operator+(Modint a, Modint b) { return Modint((a.n += b.n) >= MOD ? a.n - a.Mod : a.n); } Modint operator-(Modint a, Modint b) { return Modint((a.n -= b.n) < 0 ? a.n + a.Mod : a.n); } Modint operator*(Modint a, Modint b) { return Modint(1LL * a.n * b.n % a.Mod); } Modint &operator+=(Modint &a, Modint b) { return a = a + b; } Modint &operator-=(Modint &a, Modint b) { return a = a - b; } Modint &operator*=(Modint &a, Modint b) { return a = a * b; } typedef vector<Modint> vec; typedef vector<vec> mat; mat mul(mat &A, mat &B) { mat C(A.size(), vec(B[0].size())); for (int i = 0; i < A.size(); i++) { for (int k = 0; k < B.size(); k++) { for (int j = 0; j < B[0].size(); j++) { C[i][j] = C[i][j] + A[i][k] * B[k][j]; } } } return C; } vec mul(mat &A, vec &B) { vec C(A.size()); for (int i = 0; i < A.size(); i++) { for (int j = 0; j < B.size(); j++) { C[i] += A[i][j] * B[j]; } } return C; } mat pow(mat A, ll n) { mat B(A.size(), vec(A.size())); for (int i = 0; i < A.size(); i++) { B[i][i] = 1; } while (n > 0) { if (n & 1)B = mul(B, A); A = mul(A, A); n >>= 1; } return B; } int main() { ll n, px0, py0; cin >> n >> px0 >> py0; Modint px(px0), py(py0); vector<pll> c(n); rep(i, n) { cin >> c[i].first; if (c[i].first != 3) { cin >> c[i].second; } } vector<pll> ans(n); vec first = { px,py,1 }; mat A = { {1,0,0}, {0,1,0},{0,0,1} }; for (int i = n - 1; i >= 0; i--) { if (c[i].first == 1) { mat B = { {1,0,Modint(c[i].second)},{0,1,0},{0,0,1} }; A = mul(A, B); } else if (c[i].first == 2) { mat B = { { 1,0,0 },{ 0,1,Modint(c[i].second) },{ 0,0,1 } }; A = mul(A, B); } else { mat B = { { 0,1,0 },{ -1,0,0 },{ 0,0,1 } }; A = mul(A, B); } vec now = mul(A, first); ans[i] = pll(now[0].n, now[1].n); } rep(i, n) { cout << ans[i].first << " " << ans[i].second << endl; } }