結果
問題 | No.675 ドットちゃんたち |
ユーザー | ふっぴー |
提出日時 | 2018-04-14 00:51:53 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 225 ms / 2,000 ms |
コード長 | 2,860 bytes |
コンパイル時間 | 1,938 ms |
コンパイル使用メモリ | 180,428 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-26 22:03:34 |
合計ジャッジ時間 | 4,645 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,948 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 190 ms
6,940 KB |
testcase_06 | AC | 223 ms
6,940 KB |
testcase_07 | AC | 190 ms
6,940 KB |
testcase_08 | AC | 201 ms
6,940 KB |
testcase_09 | AC | 211 ms
6,940 KB |
testcase_10 | AC | 225 ms
6,940 KB |
testcase_11 | AC | 210 ms
6,940 KB |
ソースコード
#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<ll> 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, px, py; cin >> n >> px >> py; 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,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,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], now[1]); } rep(i, n) { cout << ans[i].first << " " << ans[i].second << endl; } }