QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#567333#9242. An Easy Geometry Problemucup-team3519Compile Error//C++204.0kb2024-09-16 11:12:042024-09-16 11:12:05

Judging History

你现在查看的是最新测评结果

  • [2024-09-16 11:12:05]
  • 评测
  • [2024-09-16 11:12:04]
  • 提交

answer

#pragma GCC O(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pi;
#define V vector
#define fi first
#define se second
#define pb push_back
#define all1(x) (x).begin() + 1, (x).end()

const int MN = 2e5 + 1000;

const LL mod = 444445555566666677;
const int base = 233;
LL pbase[MN];
LL tot1[MN];

LL mul(LL a, LL b) {
    LL res = a * b - LL(1.L * a * b / mod) * mod;
    res %= mod;
    if (res < 0) {
        res += mod;
    }
    return res;
}

LL posi(LL x) {
    if(x < 0) x += mod;
    return x;
}

LL add(LL a, LL b) {
    LL ans = a + b;
    if(ans >= mod) ans -= mod;
    return ans;
}


struct info {
    int len;
    LL hs, rhs;
}i0{0, 0, 0};

struct tag {
    LL add;
}t0{0};

struct node {
    info i;
    tag t;
}seg[MN * 4];

info operator+(info& a, info& b) {
    return {a.len + b.len, add(a.hs, mul(b.hs, pbase[a.len])), add(b.rhs, mul(a.rhs, pbase[b.len]))};
}
info operator + (info& a, tag& t) {
    return {a.len, add(a.hs, mul(tot1[a.len], posi(t.add))), add(a.rhs, mul(tot1[a.len], posi(t.add)))};
}
tag operator +(tag& a, tag& b) {
    return {a.add + b.add};
}

void pull_up(int x) {
    seg[x].i = seg[x * 2].i + seg[x * 2 + 1].i;
}

void apply(int x, tag& t) {
    seg[x].t = seg[x].t + t;
    seg[x].i = seg[x].i + t;
}

void push_down(int x) {
    if(seg[x].t.add == 0) return;
    apply(x * 2, seg[x].t);
    apply(x * 2 + 1, seg[x].t);
    seg[x].t = t0;
}

void build(V<info>& v) {
    int n = v.size() - 1;
    auto dfs = [&](int x, int l, int r, auto dfs) -> void {
        if(l == r) seg[x].i = v[l];
        else {
            int mid = l + r >> 1;
            dfs(x * 2, l, mid, dfs), dfs(x * 2 + 1, mid + 1, r, dfs);
            pull_up(x);
        }
    };
    dfs(1, 1, n, dfs);
}
info query(int x, int l, int r, int ql, int qr) {
    if(ql <= l && qr >= r) {
        return seg[x].i;
    }
    int mid = l + r >> 1;
    push_down(x);
    info ans = i0;
    if(ql <= mid) ans = ans + query(x * 2, l, mid, ql, qr);
    if(qr >= mid + 1) ans = ans + query(x * 2 + 1, mid + 1, r, ql, qr);
    return ans;
}
void modify(int x, int l, int r, int ql, int qr, tag& t) {
    if(ql <= l && qr >= r) {
        apply(x, t);
        return;
    }
    int mid = l + r >> 1;
    push_down(x);
    if(ql <= mid) modify(x * 2, l, mid, ql, qr, t);
    if(qr >= mid + 1) modify(x * 2 + 1, mid + 1, r, ql, qr, t);
    pull_up(x);
}


void solve() {
    int n; cin >> n;
    int q; cin >> q;
    int k, b; cin >> k >> b;
    V<int> a(n + 1);
    V<LL> should(n + 1);
    should[0] = 0;
    for(int i = 1; i <= n; i++) should[i] = add(mul(posi(k * i + b), pbase[i]), should[i - 1]);

    for(int i = 1; i <= n; i++) cin >> a[i];

    V<info> ini_tree(n + 1);
    for(int i = 1; i <= n; i++) {
        ini_tree[i] = {1, mul(base, posi(a[i])), mul(base, posi(a[i]))};
    }
    build(ini_tree);

    for(int i = 1; i <= q; i++) {
        int t; cin >> t;
        if(t == 1) {
            int l, r, v; cin >> l >> r >> v;
            modify(1, 1, n, l, r, {v});
        } else {
            int i; cin >> i;
            int l = 0, r = i;
            while(l != r - 1) {
                int mid = l + r >> 1;
                bool ok;
                int len = i - mid;
                if(2 * i - mid > n) ok = 0;
                else {
                    LL hs1 = query(1, 1, n, mid, i - 1).rhs;
                    LL hs2 = query(1, 1, n, i + 1, 2 * i - mid).hs;
                    if(add(mod - hs1, hs2) == should[len]) ok = 1;
                    else ok = 0;
                }
                if(ok) r = mid;
                else l = mid;
            }
            cout << i - r << "\n";
        }
    }
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0);

    pbase[0] = 1;
    for(int i = 1; i <= 2e5 + 10; i++) pbase[i] = mul(pbase[i - 1], base);
    tot1[0] = 0;
    for(int i = 1; i <= 2e5 + 10; i++) tot1[i] = add(tot1[i - 1], pbase[i]);
    // int t; cin >> t;
    int t = 1;
    while(t--) solve();
}

Details

answer.code: In function ‘info query(int, int, int, int, int)’:
answer.code:99:29: error: no match for ‘operator+’ (operand types are ‘info’ and ‘info’)
   99 |     if(ql <= mid) ans = ans + query(x * 2, l, mid, ql, qr);
      |                         ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                         |          |
      |                         info       info
answer.code:60:5: note: candidate: ‘tag operator+(tag&, tag&)’
   60 | tag operator +(tag& a, tag& b) {
      |     ^~~~~~~~
answer.code:60:21: note:   no known conversion for argument 1 from ‘info’ to ‘tag&’
   60 | tag operator +(tag& a, tag& b) {
      |                ~~~~~^
answer.code:57:6: note: candidate: ‘info operator+(info&, tag&)’
   57 | info operator + (info& a, tag& t) {
      |      ^~~~~~~~
answer.code:57:32: note:   no known conversion for argument 2 from ‘info’ to ‘tag&’
   57 | info operator + (info& a, tag& t) {
      |                           ~~~~~^
In file included from /usr/include/c++/13/bits/stl_algobase.h:67,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from answer.code:2:
/usr/include/c++/13/bits/stl_iterator.h:634:5: note: candidate: ‘template<class _Iterator> constexpr std::reverse_iterator<_IteratorL> std::operator+(typename reverse_iterator<_IteratorL>::difference_type, const reverse_iterator<_IteratorL>&)’
  634 |     operator+(typename reverse_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:634:5: note:   template argument deduction/substitution failed:
answer.code:99:58: note:   ‘info’ is not derived from ‘const std::reverse_iterator<_IteratorL>’
   99 |     if(ql <= mid) ans = ans + query(x * 2, l, mid, ql, qr);
      |                                                          ^
/usr/include/c++/13/bits/stl_iterator.h:1808:5: note: candidate: ‘template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)’
 1808 |     operator+(typename move_iterator<_Iterator>::difference_type __n,
      |     ^~~~~~~~
/usr/include/c++/13/bits/stl_iterator.h:1808:5: note:   template argument deduction/substitution failed:
answer.code:99:58: note:   ‘info’ is not derived from ‘const std::move_iterator<_IteratorL>’
   99 |     if(ql <= mid) ans = ans + query(x * 2, l, mid, ql, qr);
      |                                                          ^
In file included from /usr/include/c++/13/string:54,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52:
/usr/include/c++/13/bits/basic_string.h:3541:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)’
 3541 |     operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/basic_string.h:3541:5: note:   template argument deduction/substitution failed:
answer.code:99:58: note:   ‘info’ is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>’
   99 |     if(ql <= mid) ans = ans + query(x * 2, l, mid, ql, qr);
      |                                                          ^
/usr/include/c++/13/bits/basic_string.h:3559:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)’
 3559 |     operator+(const _CharT* __lhs,
      |     ^~~~~~~~
/usr/include/c++/13/bits/basic_string.h:3559:5: note:   template argument deduction/substitution failed:
answer.code:99:58: note:   mismatched types ‘const _CharT*’ and ‘info’
   99 |     if(ql <= mid) ans = ans + query(x * 2, l, mid, ql, qr);
      |                                                          ^
/usr/include/c++/13/bits/basic_string.h:3578:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> constexpr std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)’
 3578 |     operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/13/bits/basic_string.h:3578:5: note:   template argument deduction/substitution failed:
answer.code:99:58: note:   ‘info’ is not derived from ‘const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>’
   99 |     if(ql <= mid) ans = ans + query(x * 2, l, mid, ql, qr);
      |                                                          ^
/usr/include/c++/13/bits/basic_string.h:3595:5: note: candidate: ‘template<class _CharT, class _Traits, class _Alloc> c...