結果
問題 |
No.3207 Digital Font
|
ユーザー |
![]() |
提出日時 | 2025-07-23 17:43:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 375 ms / 3,000 ms |
コード長 | 2,974 bytes |
コンパイル時間 | 4,723 ms |
コンパイル使用メモリ | 275,504 KB |
実行使用メモリ | 24,968 KB |
最終ジャッジ日時 | 2025-07-27 13:17:21 |
合計ジャッジ時間 | 19,970 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 38 |
ソースコード
#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif #include <bits/stdc++.h> #include <cassert> #include <atcoder/all> using namespace std; using namespace atcoder; using ll = long long; using mint = modint998244353; //using mint = modint1000000007; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define repu(i, s, t) for (int i = (int)(s); i < (int)(t); i++) #define repd(i, s, t) for (int i = (int)(s)-1; i >= (int)(t); i--) #define all(v) v.begin(), v.end() void _u() { cerr << endl; } template <class H, class... T> void _u(H&& h, T&&... t) { cerr << h << ", "; _u(move(t)...); } #define U(...) { cerr << #__VA_ARGS__ << ": "; _u(__VA_ARGS__); } template<typename T> bool chmax(T &a, const T b) { if(a >= b) return false; a = b; return true; } template<typename T> bool chmin(T &a, const T b) { if(a <= b) return false; a = b; return true; } template<typename T> istream& operator>>(istream &in, vector<T> &a) { for(T &x: a) in >> x; return in; } template<typename T> ostream& operator<<(ostream &out, const vector<T> &a) { for(const T &x: a) out << x << ' '; return out; } const int di[] = {1, 0, -1, 0, 1, 1, -1, -1, 0}; const int dj[] = {0, 1, 0, -1, -1, 1, 1, -1, 0}; int main() { int h, w, n; cin >> h >> w >> n; vector<tuple<int, int, int>> num; rep(ti, n) { int i, j, x; cin >> i >> j >> x; num.emplace_back(i-1, j-1, x); } int q; cin >> q; vector<tuple<int, int, int, int>> querry; rep(i, q) { int l, d, r, u; cin >> l >> d >> r >> u; l--, d--; querry.emplace_back(l, r, d, u); } int c1 = 12345, c2 = 67890; vector<mint> pc1(h+1), pc2(w+1); pc1[0] = pc2[0] = 1; rep(i, h) pc1[i+1] = pc1[i] * c1; rep(i, w) pc2[i+1] = pc2[i] * c2; auto solve = [&]() { vector<tuple<int, int, int, int, int>> cont; for(auto[i, j, x]: num) { int px = (x * pc1[i] * pc2[j]).val(); cont.emplace_back(i, 2, j, px, -1); } rep(qi, q) { auto[l, r, d, u] = querry[qi]; cont.emplace_back(l, 1, d, u, qi); cont.emplace_back(r, -1, d, u, qi); } sort(all(cont)); vector<mint> ans(q); fenwick_tree<mint> ft(w); for(auto[i, t, t1, t2, t3]: cont) { if(t == 2) { ft.add(t1, t2); } else { ans[t3] += ft.sum(t1, t2) * t; } } rep(i, q) { auto[l, r, d, u] = querry[i]; ans[i] /= pc1[l] * pc2[d]; } return ans; }; auto res1 = solve(); vector<int> inv = {0, 1, 2, -1, -1, 5, 9, -1, 8, 6}; for(auto &[i, j, x]: num) { i = h-i-1; j = w-j-1; x = inv[x]; } for(auto &[l, r, d, u]: querry) { swap(l, r); l = h-l, r = h-r; swap(d, u); d = w-d, u = w-u; } auto res2 = solve(); rep(i, q) cout << (res1[i] == res2[i] ? "Yes" : "No") << '\n'; return 0; }