結果
問題 | No.2540 同値性判定 |
ユーザー | Kude |
提出日時 | 2023-11-10 23:53:21 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 49 ms / 2,500 ms |
コード長 | 3,780 bytes |
コンパイル時間 | 3,731 ms |
コンパイル使用メモリ | 281,668 KB |
実行使用メモリ | 51,724 KB |
最終ジャッジ日時 | 2024-09-26 02:27:52 |
合計ジャッジ時間 | 7,610 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,944 KB |
testcase_12 | AC | 2 ms
6,940 KB |
testcase_13 | AC | 3 ms
6,944 KB |
testcase_14 | AC | 6 ms
8,804 KB |
testcase_15 | AC | 33 ms
51,628 KB |
testcase_16 | AC | 49 ms
51,620 KB |
testcase_17 | AC | 47 ms
51,628 KB |
testcase_18 | AC | 47 ms
51,656 KB |
testcase_19 | AC | 45 ms
51,648 KB |
testcase_20 | AC | 47 ms
51,556 KB |
testcase_21 | AC | 48 ms
51,672 KB |
testcase_22 | AC | 49 ms
51,724 KB |
testcase_23 | AC | 47 ms
51,700 KB |
testcase_24 | AC | 47 ms
51,676 KB |
evil_00.txt | AC | 165 ms
51,648 KB |
evil_01.txt | AC | 167 ms
51,700 KB |
evil_02.txt | AC | 139 ms
51,580 KB |
evil_03.txt | AC | 157 ms
51,584 KB |
evil_04.txt | AC | 179 ms
51,484 KB |
evil_05.txt | AC | 176 ms
51,552 KB |
evil_06.txt | AC | 146 ms
51,584 KB |
evil_07.txt | AC | 149 ms
51,584 KB |
evil_08.txt | AC | 186 ms
51,584 KB |
evil_09.txt | AC | 193 ms
51,584 KB |
evil_10.txt | AC | 200 ms
51,456 KB |
evil_11.txt | AC | 189 ms
51,456 KB |
ソースコード
#include<bits/stdc++.h> namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include<atcoder/all> #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair<int,int>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; template <class F, F (*composition)(F, F), F (*id)()> struct dual_segtree { public: dual_segtree() : dual_segtree(0) {} explicit dual_segtree(int n) : dual_segtree(std::vector<F>(n, id())) {} explicit dual_segtree(const std::vector<F>& v) : _n(int(v.size())) { auto ceil_log2 = [](int n) { int x = 0; while ((1U << x) < (unsigned int)(n)) x++; return x; }; log = ceil_log2(_n); size = 1 << log; lz = std::vector<F>(2 * size, id()); for (int i = 0; i < _n; i++) lz[size + i] = v[i]; } void set(int p, F x) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); lz[p] = x; } F get(int p) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); return lz[p]; } void apply(int p, F f) { assert(0 <= p && p < _n); p += size; for (int i = log; i >= 1; i--) push(p >> i); lz[p] = composition(f, lz[p]); } void apply(int l, int r, F f) { assert(0 <= l && l <= r && r <= _n); if (l == r) return; l += size; r += size; for (int i = log; i >= 1; i--) { if (((l >> i) << i) != l) push(l >> i); if (((r >> i) << i) != r) push((r - 1) >> i); } while (l < r) { if (l & 1) all_apply(l++, f); if (r & 1) all_apply(--r, f); l >>= 1; r >>= 1; } } void push_all() { for (int i = 1; i < size; i++) push(i); } F get_raw(int p) { assert(0 <= p && p < _n); return lz[size + p]; } private: int _n, size, log; std::vector<F> lz; void all_apply(int k, F f) { lz[k] = composition(f, lz[k]); } void push(int k) { all_apply(2 * k, lz[k]); all_apply(2 * k + 1, lz[k]); lz[k] = id(); } }; using ull = unsigned long long; struct F { ull a, b; }; F composition(F f, F g) { // fa(gax+gb)+fb return F{f.a & g.a, (f.a & g.b) ^ f.b}; } F id() { return {~0ULL, 0}; } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, q; cin >> n >> q; ull p[6]{}; rep(s, 1 << 6) { rep(k, 6) p[k] |= ull(s >> k & 1) << s; } vector<F> init(n); rep(i, n) init[i] = F{0ULL, p[i % 6]}; dual_segtree<F, composition, id> seg(init); rep(_, q) { int h, l1, r1, l2, r2; string o; cin >> h >> o >> l1 >> r1 >> l2 >> r2; r1++, r2++; ull y = seg.get(h).b; F f; if (o == "land") { f = F{y, 0}; } else if (o == "lor") { f = F{y ^ ~0ULL, y}; } else { assert(o == "Rightarrow"); f = F{y ^ ~0ULL, ~0ULL}; } seg.apply(l1, r1, f); set<ull> seen; bool ok = false; for (int i = l2; i < r2; i++) { ull x = seg.get(i).b; if (seen.contains(x)) { ok = true; break; } seen.insert(x); } cout << (ok ? "Yes\n" : "No\n"); } }