結果
問題 | No.1810 RGB Biscuits |
ユーザー | Novi |
提出日時 | 2022-01-15 11:50:56 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 5,088 bytes |
コンパイル時間 | 4,776 ms |
コンパイル使用メモリ | 240,456 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-21 11:11:46 |
合計ジャッジ時間 | 5,367 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> using namespace std; using ll = long long; #define int ll #define rng(i, a, b) for (int i = int(a); i < int(b); i++) #define rep(i, b) rng(i, 0, b) #define ALL(a) (a).begin(), (a).end() template <class t, class u> void chmax(t& a, u b) { if (a < b) a = b; } template <class t, class u> void chmin(t& a, u b) { if (b < a) a = b; } template <class t> using vc = vector<t>; template <class t> using vvc = vc<vc<t>>; using pi = pair<int, int>; using vi = vc<int>; using uint = unsigned; using ull = unsigned long long; int popcount(signed t) { return __builtin_popcount(t); } int popcount(ll t) { return __builtin_popcountll(t); } bool ispow2(int i) { return i && (i & -i) == i; } ll mask(int i) { return (ll(1) << i) - 1; } int lcm(int a, int b) { return a / __gcd(a, b) * b; } using mint = atcoder::modint1000000007; typedef mint Type; typedef vector<vector<Type>> Matrix; int GetRank(Matrix a) { int h = a.size(), w = a[0].size(); int res = 0, now = 0; for (int i = 0; i < h; i++) { Type ma = 0; int pivot; for (int j = i; j < h; j++) { if (a[j][now].val() > ma.val()) { ma = a[j][now]; pivot = j; } } if (ma.val() == 0) { now++; if (now == w) break; i--; continue; } if (pivot != i) { for (int j = 0; j < w; j++) { swap(a[i][j], a[pivot][j]); } } Type tmp = 1 / a[i][now]; for (int j = 0; j < w; j++) a[i][j] *= tmp; for (int j = 0; j < h; j++) { if (i != j) { Type tmp2 = a[j][now]; for (int k = 0; k < w; k++) { a[j][k] -= a[i][k] * tmp2; } } } res++; } return res; } bool Inv(Matrix a, Matrix& inv) { assert(a.size() == a[0].size() && inv.size() == inv[0].size()); int n = a.size(); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { inv[i][j] = (i == j ? 1 : 0); } } for (int i = 0; i < n; i++) { Type ma = 0; int pivot; for (int j = i; j < n; j++) { if (a[j][i].val() > ma.val()) { ma = a[j][i]; pivot = j; } } if (ma == 0) return false; if (pivot != i) { for (int j = 0; j < n; j++) { swap(a[i][j], a[pivot][j]); swap(inv[i][j], inv[pivot][j]); } } Type tmp = 1 / a[i][i]; for (int j = 0; j < n; j++) { a[i][j] *= tmp; inv[i][j] *= tmp; } for (int j = 0; j < n; j++) { if (i != j) { Type tmp2 = a[j][i]; for (int k = 0; k < n; k++) { a[j][k] -= a[i][k] * tmp2; inv[j][k] -= inv[i][k] * tmp2; } } } } return true; } Matrix Add(const Matrix& a, const Matrix& b, bool minus = false) { assert(a.size() == b.size() && a[0].size() == b[0].size()); int h = a.size(), w = a[0].size(); Matrix c(h, vector<Type>(w)); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { c[i][j] = a[i][j] + (minus ? -1 : 1) * b[i][j]; } } return c; } Matrix Sub(const Matrix& a, const Matrix& b) { return Add(a, b, true); } Matrix Mul(const Matrix& a, const Matrix& b) { assert(a[0].size() == b.size()); Matrix c(a.size(), vector<Type>(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; } Matrix Pow(Matrix a, long long n) { assert(a.size() == a[0].size()); Matrix b(a.size(), vector<Type>(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; } void PrintMatrix(const Matrix& a) { int h = a.size(), w = a[0].size(); for (int i = 0; i < h; i++) { for (int j = 0; j < w; j++) { cout << a[i][j].val() << ' '; } cout << endl; } } signed main() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20); int A, B; cin >> A >> B; int n; cin >> n; vi t(n); rep(i, n) cin >> t[i]; Matrix p = {{A, B}, {0, 0}}; rep(i, n) { // a1=0,a0=0 mint r, g, b, sum; if (t[i] % 2 == 0) { auto cur = Pow(p, t[i] / 2); r = p[0][0] + p[0][1]; g = p[1][0] + p[1][1]; b = 0; } else { auto cur = Pow(p, t[i] / 2); r = p[0][0] + p[0][1]; g = p[1][0] + p[1][1]; b = A * r + B * g; } sum = r + g + b; cout << sum.val() << endl; } }