QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#369961#7782. Ursa Minor1234huangWA 355ms23516kbC++204.4kb2024-03-28 20:08:352024-03-28 20:08:36

Judging History

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

  • [2024-03-28 20:08:36]
  • 评测
  • 测评结果:WA
  • 用时:355ms
  • 内存:23516kb
  • [2024-03-28 20:08:35]
  • 提交

answer

#include <bits/stdc++.h>
#define ull unsigned int
using namespace std;

inline int read() {
	int x = 0, f = 0; char ch = getchar();
	while (ch < '0' or ch > '9') f |= (ch == '-'), ch = getchar();
	while (ch >= '0' and ch <= '9') x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}

int __stk[128], __top;
inline void write(int x) {
    if(x < 0) putchar('-'), x = -x;
	do { __stk[++__top] = x % 10, x /= 10; } while (x);
	while (__top) putchar(__stk[__top--] + '0');
}

const int mod = 998244353;

void Min(int &x, int y) { y < x and (x = y); }
void Max(int &x, int y) { y > x and (x = y); }

void inc(int &x, int y) { (x += y) >= mod and (x -= mod); }
void mul(int &x, int y) { x = 1ll * x * y % mod; }

int q_pow(int x, int k) { int res = 1; for (; k; k >>= 1, mul(x, x)) if (k & 1) mul(res, x); return res; }

bool stmer;

const int N = 2e5 + 10, M = 500, BL = 447;
const ull base = 127;

int n, m, q;

ull a[N], b[N], s[N];

namespace ST {
    const int LG = 20;

    int lg[N], st[LG][N];

    void init() {
        for (int i = 2; i <= m; i++) lg[i] = lg[i >> 1] + 1;
        for (int i = 1; i < LG; i++) for (int j = 1; j + (1 << i) - 1 <= m; j++)
            st[i][j] = __gcd(st[i - 1][j], st[i - 1][j + (1 << i - 1)]);
    }

    int ask(int l, int r) {
        int h = lg[r - l + 1];
        return __gcd(st[h][l], st[h][r - (1 << h) + 1]);
    }
}

namespace Block1 {
    ull S1[M][M], S2[M][M];

    void init() {
        for (int bl = 1; bl < BL; bl++) for (int i = 1; i <= n; i++) {
            int id = i / BL; ull w = a[i] * b[i % bl];
            S1[bl][id] += w, S2[bl][id] += (i % bl ? 0 : w);
        }
    }

    void modify(int p, ull v) {
        for (int bl = 1; bl < BL; bl++) {
            int id = p / BL; ull w = (v - a[p]) * b[p % bl];
            S1[bl][id] += w, S2[bl][id] += (p % bl ? 0 : w);
        }
    }

    bool query(int l, int r, int k) {
        int L = l / BL + 1, R = r / BL - 1; ull res = 0, s0 = 0, w;
        for (int i = L; i <= R; i++) res += S1[k][i], s0 += S2[k][i];
        while (l <= min(L * BL - 1 , r)) res += (w = a[l] * b[l % k]), s0 += (l++ % k ? 0 : w);
        while (r >= max(R * BL + BL, l)) res += (w = a[r] * b[r % k]), s0 += (r-- % k ? 0 : w);
        return res == s0 * s[k - 1];
    }
}

namespace Block2 {
    ull S1[M][M], S2[M];

    void init() {
        for (int i = 1; i <= n; i++) {
            int id = i / BL;
            S2[id] += (S1[id][i % BL] = a[i] * b[i]);
        }
        for (int i = 0; i <= n / BL; i++) {
            for (int j = 1; j < BL; j++) S1[i][j] += S1[i][j - 1];
            if (i) S2[i] += S2[i - 1];
        }
    }

    void modify(int p, ull v) {
        int id = p / BL; ull w = (v - a[p]) * b[p];
        for (int i = p % BL; i < BL; i++) S1[id][i] += w;
        for (int i = id; i <= n / BL; i++) S2[i] += w;
    }

    ull ask(int l, int r) {
        ull res = (r < BL ? 0 : S2[r / BL - 1]) - (l < BL ? 0 : S2[l / BL - 1]);
        return res + S1[r / BL][r % BL] - (l % BL ? S1[l / BL][l % BL - 1] : 0); 
    }

    bool query(int l, int r, int k) {
        ull res = 0, s0 = 0;
        while (l <= r) res *= b[k] += ask(l, l + k - 1), s0 += a[l], l += k;
        return res == s0 * s[k - 1] * b[l - k];
    }
}

bool edmer;
signed main() {
	// freopen("gym104869F.in", "r", stdin);
	// freopen("gym104869F.out", "w", stdout);
	cerr << "[Memory] " << (&stmer - &edmer) / 1024 / 1024 << " MB\n";
	
    n = read(), m = read(), q = read();
    for (int i = 1; i <= n; i++) a[i] = read();
    for (int i = 1; i <= m; i++) ST :: st[0][i] = read();
    
    ST :: init(), b[0] = s[0] = 1;
    for (int i = 1; i < N; i++) s[i] = s[i - 1] + (b[i] = b[i - 1] * base);

    Block1 :: init(), Block2 :: init();
    while (q--) {
        char ch = getchar();
        while (ch != 'U' and ch != 'Q') ch = getchar();
        if (ch == 'U') {
            int p = read(), v = read();
            Block1 :: modify(p, v), Block2 :: modify(p, v), a[p] = v;
        }
        else {
            int l = read(), r = read(), s = read(), t = read();
            int k = __gcd(r - l + 1, ST :: ask(s, t));
            if (k < BL) puts(Block1 :: query(l, r, k) ? "Yes" : "No");
            else puts(Block2 :: query(l, r, k) ? "Yes" : "No");
        }
    }

    cerr << "[Runtime] " << (double) clock() / CLOCKS_PER_SEC << " seconds\n";
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 12248kb

input:

6 4 5
1 1 4 5 1 4
3 3 2 4
Q 1 5 1 2
Q 2 5 3 4
U 5 2
Q 1 6 1 2
Q 2 5 3 4

output:

Yes
No
No
Yes

result:

ok 4 tokens

Test #2:

score: 0
Accepted
time: 2ms
memory: 10000kb

input:

1 1 1
0
1
Q 1 1 1 1

output:

Yes

result:

ok "Yes"

Test #3:

score: 0
Accepted
time: 99ms
memory: 16640kb

input:

2000 2000 200000
1 1 2 0 0 2 0 2 0 0 0 0 0 2 2 1 2 0 0 2 2 2 1 0 1 2 1 2 0 0 1 1 1 2 0 0 2 2 2 2 0 2 0 0 2 1 2 0 0 1 2 2 1 0 2 0 0 0 1 2 2 1 2 2 0 0 1 1 1 0 0 2 0 0 1 1 0 2 2 2 1 0 0 1 0 1 2 2 2 1 1 2 2 1 2 1 0 2 2 3 1 3 2 3 1 0 1 2 0 1 1 1 0 2 2 3 2 0 3 2 3 3 1 2 3 1 2 0 1 0 3 1 0 0 2 0 1 2 1 3 2 2...

output:

Yes
Yes
No
Yes
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No
Yes
Yes
No
No
No
No
No
Yes
No
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
No
Yes
Yes
Yes
No
No
Yes
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
Yes
Yes
Yes
No...

result:

ok 100554 tokens

Test #4:

score: 0
Accepted
time: 114ms
memory: 22676kb

input:

1 200000 200000
998244353
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
...

result:

ok 100240 tokens

Test #5:

score: 0
Accepted
time: 104ms
memory: 22404kb

input:

6 131072 200000
0 0 0 0 1000000000 1000000000
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...

output:

Yes
Yes
Yes
No
No
No
Yes
No
No
No
No
No
Yes
Yes
No
Yes
No
Yes
Yes
Yes
No
No
No
No
No
No
No
Yes
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
No
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
Yes
Yes
No
Yes
N...

result:

ok 100021 tokens

Test #6:

score: -100
Wrong Answer
time: 355ms
memory: 23516kb

input:

200000 200000 200000
490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877 490339877...

output:

No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
Yes
Yes
Yes
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
Yes
Yes
No
No
No
No
No
No
No
No
N...

result:

wrong answer 1043rd words differ - expected: 'Yes', found: 'No'