QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#386516#7782. Ursa MinorA_programmerCompile Error//C++174.4kb2024-04-11 17:49:252024-04-11 17:49:26

Judging History

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

  • [2024-04-11 17:49:26]
  • 评测
  • [2024-04-11 17:49:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
const ll Base = 10;
const int B = 455;
const int maxn = 2e5 + 5;

int a[maxn], b[maxn], f[maxn][18], lg[maxn];
inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int query(int l, int r)
{
    int k = lg[r - l + 1];
    return gcd(f[l][k], f[r - (1 << k) + 1][k]);
}

ll fpow(ll a, ll b)
{
    ll ans = 1;
    while (b)
    {
        if (b & 1) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans;
}

ll mi[maxn], inv[maxn], pre[maxn], iBase;
int bs, bn, bl[maxn], br[maxn], bel[maxn];

struct ds1 // O(1) query to O(sqrt(n)) update  a_i * x^i
{
    ll c[maxn], tag[maxn];
    void add(int pos, ll x)
    {
        for (int i = pos; i <= br[bel[pos]]; i++) (c[i] += x) %= mod;
        for (int i = bel[pos] + 1; i <= bn; i++) (tag[i] += x) %= mod;
    }
    ll sum(int pos) { return (c[pos] + tag[bel[pos]]) % mod; }
}ds1;

struct ds2 // O(sqrt(n)) query to O(1) update a_i * x^(i % k)
{
    ll c[maxn], sum[maxn];
    ll d[maxn], sud[maxn];
    void add(int pos, ll x) { (c[pos] += x) %= mod; (sum[bel[pos]] += x) %= mod; }
    void addD(int pos, ll x) { (d[pos] += x) %= mod; (sud[bel[pos]] += x) %= mod; }
    ll sumP(int pos)
    {
        ll ans = 0;
        for (int i = 1; i < bel[pos]; i++) (ans += sum[i]) %= mod;
        for (int i = bl[bel[pos]]; i <= pos; i++) (ans += c[i]) %= mod;
        return ans;
    }
    ll sumD(int pos)
    {
        ll ans = 0;
        for (int i = 1; i < bel[pos]; i++) (ans += sud[i]) %= mod;
        for (int i = bl[bel[pos]]; i <= pos; i++) (ans += d[i]) %= mod;
        return ans;
    }
}ds2[B];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m, q;
    cin >> n >> m >> q;
    mi[0] = inv[0] = pre[0] = 1; iBase = fpow(Base, mod - 2);
    for (int i = 1; i <= n; i++) mi[i] = mi[i - 1] * Base % mod, pre[i] = (pre[i - 1] + mi[i]) % mod;
    for (int i = 1; i <= n; i++) inv[i] = inv[i - 1] * iBase % mod;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1, k = 0; i <= m; i++)
    {
        cin >> b[i], f[i][0] = b[i];
        lg[i] = k;
        if (i == (1 << (k + 1))) lg[i] = ++k;
    }
    for (int j = 1; j <= 17; j++)
        for (int i = 1; i + (1 << j) - 1 <= m; i++)
            f[i][j] = gcd(f[i][j - 1], f[i + (1 << (j - 1))][j - 1]);
    
    bs = max(1, (int)sqrt(n) - 100);
    for (int i = 1; i <= n; i += bs)
        bl[++bn] = i, br[bn] = i + bs - 1;
    br[bn] = n;
    for (int i = 1; i <= bn; i++)
        for (int j = bl[i]; j <= br[i]; j++) bel[j] = i;
    
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= bs; j++)
        {
            ds2[j].add(i, a[i] * mi[i % j] % mod);
            if (i % j == 0) ds2[j].addD(i, a[i]);
        }
        ds1.add(i, a[i] * mi[i] % mod);
    }

    while (q--)
    {
        char s[4];
        cin >> s;
        if (s[0] == 'U')
        {
            int pos;
            ll v;
            cin >> pos >> v;
            v = (v + mod - a[pos]) % mod;
            for (int i = 1; i <= bs; i++)
            {
                ds2[i].add(pos, v * mi[pos % i] % mod);
                if (pos % i == 0) ds2[i].addD(pos, v);
            }
            ds1.add(pos, v * mi[pos] % mod);
            (a[pos] += v) %= mod;
        }
        else
        {
            int l, r, s, t;
            cin >> l >> r >> s >> t;
            int k = gcd(r - l + 1, query(s, t));
            ll hsh = 0, hs2 = 0;
            if (k <= bs)
            {
                hsh = ds2[k].sumP(r) - ds2[k].sumP(l - 1);
                hs2 = ds2[k].sumD(r) - ds2[k].sumD(l - 1);
                if (hsh < 0) hsh += mod;
                if (hs2 < 0) hs2 += mod;
            }
            else
            {
                for (int i = l; i <= r; i += k) (hs2 += a[i]) %= mod;
                for (int i = l / k; i <= r / k; i++)
                {
                    int L = i * k, R = L + k - 1;
                    L = max(L, l), R = min(R, r);
                    if (L > R) continue;
                    ll res = (ds1.sum(R) + mod - ds1.sum(L - 1)) * inv[i * k] % mod;
                    (hsh += res) %= mod;
                }
            }
            (hs2 *= pre[k - 1]) %= mod;
            cout << (hsh == hs2 ? "Yes\n" : "No\n");
        }
    }
    return 0;
}

详细

/tmp/ccZkWOoh.o: in function `query(int, int)':
answer.code:(.text+0xc): relocation truncated to fit: R_X86_64_PC32 against symbol `lg' defined in .bss section in /tmp/ccZkWOoh.o
answer.code:(.text+0x1b): relocation truncated to fit: R_X86_64_PC32 against symbol `f' defined in .bss section in /tmp/ccZkWOoh.o
/tmp/ccZkWOoh.o: in function `main':
answer.code:(.text.startup+0x70): relocation truncated to fit: R_X86_64_PC32 against symbol `pre' defined in .bss section in /tmp/ccZkWOoh.o
answer.code:(.text.startup+0x7b): relocation truncated to fit: R_X86_64_PC32 against symbol `inv' defined in .bss section in /tmp/ccZkWOoh.o
answer.code:(.text.startup+0x9b): relocation truncated to fit: R_X86_64_PC32 against symbol `mi' defined in .bss section in /tmp/ccZkWOoh.o
answer.code:(.text.startup+0x227): relocation truncated to fit: R_X86_64_PC32 against symbol `iBase' defined in .bss section in /tmp/ccZkWOoh.o
answer.code:(.text.startup+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `mi' defined in .bss section in /tmp/ccZkWOoh.o
answer.code:(.text.startup+0x25f): relocation truncated to fit: R_X86_64_PC32 against symbol `pre' defined in .bss section in /tmp/ccZkWOoh.o
answer.code:(.text.startup+0x27b): relocation truncated to fit: R_X86_64_PC32 against symbol `mi' defined in .bss section in /tmp/ccZkWOoh.o
answer.code:(.text.startup+0x286): relocation truncated to fit: R_X86_64_PC32 against symbol `pre' defined in .bss section in /tmp/ccZkWOoh.o
answer.code:(.text.startup+0x357): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status