結果
| 問題 |
No.3227 Matrix Query
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-08-08 23:02:57 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,570 bytes |
| コンパイル時間 | 5,591 ms |
| コンパイル使用メモリ | 266,432 KB |
| 実行使用メモリ | 9,728 KB |
| 最終ジャッジ日時 | 2025-08-08 23:03:38 |
| 合計ジャッジ時間 | 35,283 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 WA * 14 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long; using mint=modint998244353; using ld = long double;
const ll infl = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const vector<int> dx = {1, 0, -1, 0}; const vector<int> dy = {0, 1, 0, -1};
template<typename T> using vc = vector<T>; template<typename T> using vvc = vc<vc<T>>; template<typename T> using vvvc = vc<vvc<T>>;
using vi = vc<int>; using vvi = vvc<int>; using vl = vc<ll>; using vvl = vvc<ll>; using vvvl = vvc<vl>; using vvvvl = vvc<vvl>;
using vs = vc<string>; using vvs = vvc<string>; using P = pair<ll, ll>;
#define nrep(i,n) for (ll i = 0; i < (n); ++i)
#define nfor(i,s,n) for(ll i=s;i<n;i++)//i=s,s+1...n-1 ノーマルfor
#define vc_cout(v){ll n = v.size();nrep(i,n)cout<<v[i]<<" \n"[i+1==n];}//一次元配列を出力する
#define vv_cout(v){ll n = v.size();nrep(i,n){nrep(j,v[i].size()){cout<<v[i][j]<<' ';}cout<<endl;}}//二次元配列を出力する
template<class T> using pq = priority_queue<T, vc<T>>;//★大きい順に取り出す コスト,頂点 bfs系で使う 小さい順じゃないですABC305E
template<class T> using pq_g = priority_queue<T, vc<T>, greater<T>>;//小さい順に取り出す ダイクストラ法で使う
#define cout(n) cout<<n<<endl;
ll K;
struct Matrix {
vvl v;
Matrix() : v(2, vl(2, 0)) {}
Matrix(const vvl& vv) : v(vv) {}
};
Matrix op(Matrix a, Matrix b) {
vvl c(2, vl(2, 0));
for(int i=0;i<2;i++) for(int j=0;j<2;j++) for(int k=0;k<2;k++)
c[i][j] = (c[i][j] + a.v[i][k]*b.v[k][j]) % K;
return Matrix(c);
}
Matrix e() {
return Matrix({{1,0},{0,1}});
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
ll N; cin >> K >> N;
segtree<Matrix, op, e> seg(N);
nrep(i, N) {
vvl mat(2, vl(2));
nrep(r,2) nrep(c,2) {
cin >> mat[r][c];
mat[r][c] = (mat[r][c] + (ll)1e9 / K * K) % K;
}
seg.set(i, Matrix(mat));
}
ll Q; cin >> Q;
while (Q--) {
ll i, l, r; cin >> i >> l >> r;
--i; --l; --r;
vvl y(2, vl(2));
nrep(r,2) nrep(c,2) {
cin >> y[r][c];
y[r][c] = (y[r][c] + (ll)1e9 / K * K) % K;
}
seg.set(i, Matrix(y));
Matrix res = seg.prod(l, r + 1);
nrep(r,2) cout << res.v[r][0] % K << ' ' << res.v[r][1] % K << '\n';
}
}