結果
問題 |
No.3207 Digital Font
|
ユーザー |
![]() |
提出日時 | 2025-07-18 22:19:14 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 5,188 bytes |
コンパイル時間 | 3,321 ms |
コンパイル使用メモリ | 286,504 KB |
実行使用メモリ | 68,764 KB |
最終ジャッジ日時 | 2025-07-18 22:19:26 |
合計ジャッジ時間 | 11,457 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 RE * 1 |
other | AC * 9 WA * 9 RE * 20 |
ソースコード
// #pragma GCC target("avx2") // #pragma GCC optimize("O3") // #pragma GCC optimize("unroll-loops") #include<bits/stdc++.h> using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; using ld = long double; template<class T> using V = vector<T>; template<class T> using VV = V<V<T>>; template<class T> using VVV = V<VV<T>>; template<class T> using VVVV = VV<VV<T>>; #define rep(i,n) for(ll i=0ll;(i)<(n);(i)++) #define REP(i,a,n) for(ll i=(a);(i)<(n);(i)++) #define rrep(i,n) for(ll i=(n)-1;(i)>=(0ll);(i)--) #define RREP(i,a,n) for(ll i=(n)-1;(i)>=(a);(i)--) const long long INF = (1LL << 60); const long long mod99 = 998244353; const long long mod107 = 1000000007; const long long mod = mod99; #define eb emplace_back #define be(v) (v).begin(),(v).end() #define all(v) (v).begin(),(v).end() #define foa(i,v) for(auto& (i) : (v)) #define UQ(v) sort(be(v)), (v).erase(unique(be(v)), (v).end()) #define UQ2(v,cmp) sort(be(v)), (v).erase(unique(be(v),cmp), (v).end()) #define UQ3(v,cmp) sort(be(v),cmp), (v).erase(unique(be(v)), (v).end()) #define UQ4(v,cmp,cmp2) sort(be(v), cmp), (v).erase(unique(be(v),cmp2), (v).end()) #define LB(x,v) (lower_bound(be(v),(x))-(v).begin()) #define LB2(x,v,cmp) (lower_bound(be(v),(x),(cmp))-(v).begin()) #define UB(x,v) (upper_bound(be(v),(x))-(v).begin()) #define UB2(x,v,cmp) (upper_bound(be(v),(x),(cmp))-(v).begin()) #define dout() cout << fixed << setprecision(20) #define randinit() srand((unsigned)time(NULL)) template<class T, class U> bool chmin(T& t, const U& u) { if (t > u){ t = u; return 1;} return 0; } template<class T, class U> bool chmax(T& t, const U& u) { if (t < u){ t = u; return 1;} return 0; } ll Rnd(ll L=0, ll R=mod99){return rand()%(R-L)+L;} template<typename T, typename F> struct SegmentTree2D { private: int id(int h, int w) const { return h * 2 * W + w; } public: int H, W; vector<T> seg; const F f; const T I; SegmentTree2D(int h, int w, F _f, const T& i) : f(_f), I(i) { init(h, w); } void init(int h, int w) { H = W = 1; while(H < h) H <<= 1; while(W < w) W <<= 1; seg.assign(4 * H * W, I); } void set(int h, int w, const T& x) { seg[id(h + H, w + W)] = x; } void build() { for(int w = W; w < 2 * W; w++) { for(int h = H - 1; h; h--) { seg[id(h, w)] = f(seg[id(2 * h + 0, w)], seg[id(2 * h + 1, w)]); } } for(int h = 0; h < 2 * H; h++) { for(int w = W - 1; w; w--) { seg[id(h, w)] = f(seg[id(h, 2 * w + 0)], seg[id(h, 2 * w + 1)]); } } } T get(int h, int w) const { return seg[id(h + H, w + W)]; } T operator()(int h, int w) const { return seg[id(h + H, w + W)]; } void update(int h, int w, const T& x) { h += H, w += W; seg[id(h, w)] = x; for(int i = h >> 1; i; i >>= 1) { seg[id(i, w)] = f(seg[id(2 * i + 0, w)], seg[id(2 * i + 1, w)]); } for(; h; h >>= 1) { for(int j = w >> 1; j; j >>= 1) { seg[id(h, j)] = f(seg[id(h, 2 * j + 0)], seg[id(h, 2 * j + 1)]); } } } T _inner_query(int h, int w1, int w2) { T res = I; for(; w1 < w2; w1 >>= 1, w2 >>= 1) { if(w1 & 1) res = f(res, seg[id(h, w1)]), w1++; if(w2 & 1) --w2, res = f(res, seg[id(h, w2)]); } return res; } T query(int h1, int w1, int h2, int w2) { if(h1 >= h2 || w1 >= w2) return I; T res = I; h1 += H, h2 += H, w1 += W, w2 += W; for(; h1 < h2; h1 >>= 1, h2 >>= 1) { if(h1 & 1) res = f(res, _inner_query(h1, w1, w2)), h1++; if(h2 & 1) --h2, res = f(res, _inner_query(h2, w1, w2)); } return res; } }; void solve(){ using u64 = uint64_t; const u64 MOD = (LLONG_MAX) / 4; auto add = [&](u64 a, u64 b) -> u64 { a += b; if(a >= MOD) a -= MOD; return a; }; auto mul = [&](u64 a, u64 b) -> u64 { auto c = (__uint128_t)a * b; return add(c >> 61, c & MOD); }; ll h,w,n; cin >> h >> w >> n; const u64 r = Rnd(); SegmentTree2D seg1(h, w, [&](pair<u64, u64> a, pair<u64, u64> b) { return pair<u64, u64>{add(mul(a.first, b.second), b.first), mul(a.second, b.second)}; }, pair<u64, u64>{0, 1}); SegmentTree2D seg2(h, w, [&](pair<u64, u64> a, pair<u64, u64> b) { return pair<u64, u64>{add(mul(a.first, b.second), b.first), mul(a.second, b.second)}; }, pair<u64, u64>{0, 1}); rep(i, h) rep(j, w) seg1.set(i, j, {r, 908}), seg2.set(i, j, {r, 908}); rep(i, n){ ll a,b,x; cin >> a >> b >> x; a--; b--; seg1.set(a, b, {r + x, 908}); if(x == 6 or x == 9) x = 15 - x; seg2.set(h-a-1, w-b-1, {r + x, 908}); } seg1.build(); seg2.build(); ll q; cin >> q; rep(i, q){ ll a,b,c,d; cin >> a >> b >> c >> d; a--; b--; u64 A = seg1.query(a, b, c, d).first; u64 B = seg2.query(h-c, w-d, h-a, w-b).first; // cout << A << " " << B << endl; if(A == B) cout << "Yes\n"; else cout << "No\n"; } } int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int t=1; // cin >> t; rep(i,t) solve(); }