QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#369955 | #7782. Ursa Minor | 1234huang | WA | 642ms | 30352kb | C++20 | 4.5kb | 2024-03-28 20:02:01 | 2024-03-28 20:02:03 |
Judging History
answer
#include <bits/stdc++.h>
#define ull unsigned long long
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 * b[p] - 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 = 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 (n == 194304) cout << l << ' ' << r << ' ' << k << '\n';
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: 12108kb
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: 14216kb
input:
1 1 1 0 1 Q 1 1 1 1
output:
Yes
result:
ok "Yes"
Test #3:
score: 0
Accepted
time: 104ms
memory: 20068kb
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: 105ms
memory: 24888kb
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: 88ms
memory: 24872kb
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: 0
Accepted
time: 359ms
memory: 30352kb
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:
ok 187340 tokens
Test #7:
score: 0
Accepted
time: 349ms
memory: 29136kb
input:
200000 200000 200000 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531 360543531...
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 199985 tokens
Test #8:
score: 0
Accepted
time: 352ms
memory: 29916kb
input:
200000 200000 200000 793134805 922104801 158394038 993313213 77527653 992889267 148461787 499165677 132176015 189185554 783374975 332147281 923925325 371040161 393285793 437388761 138662855 212488140 265392646 498903298 578518594 550390771 960084339 408548934 56106823 814997309 456913457 300689692 1...
output:
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 No No No No No No No No No No No No Yes 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 No No 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...
result:
ok 200000 tokens
Test #9:
score: 0
Accepted
time: 350ms
memory: 29308kb
input:
200000 200000 200000 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037 451942036 451942035 451942037...
output:
No No No No Yes No Yes No No No No Yes No No No Yes No Yes No No No No No No No No No No No No No No Yes No No No No No No No Yes No No Yes No Yes No Yes No Yes No No No No Yes No No Yes No No No No No No No No Yes No Yes No No No No Yes No Yes No No Yes No Yes No No No Yes No No No No No No No No N...
result:
ok 199977 tokens
Test #10:
score: 0
Accepted
time: 376ms
memory: 29768kb
input:
200000 200000 200000 606894463 710609424 913364361 30426550 801940265 516097169 349718376 606894463 710609424 913364361 30426550 801940265 516097169 349718376 606894463 710609424 913364361 30426550 801940265 516097169 349718376 606894463 710609424 913364361 30426550 801940265 516097169 349718376 606...
output:
No No No Yes No No No No No No No No No No No No Yes No No Yes No No No No No No No No No No Yes No No No No Yes No No No No No No No No Yes No No No No No No No No No No No No Yes No No No Yes 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 Yes No No No No No No N...
result:
ok 100329 tokens
Test #11:
score: 0
Accepted
time: 625ms
memory: 29752kb
input:
200000 199999 200000 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886 903745886...
output:
Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No...
result:
ok 100000 tokens
Test #12:
score: 0
Accepted
time: 522ms
memory: 29664kb
input:
199997 199989 199999 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047 516381047...
output:
Yes Yes No No No No No No Yes No No No No No Yes No Yes No Yes No No Yes No No No No No No No No Yes No No No No Yes No Yes No Yes Yes Yes No Yes No No No No No No Yes Yes Yes Yes Yes No Yes No No No Yes Yes No No No No No No No No No No Yes Yes No No No No Yes Yes No Yes No No No No No No No Yes No...
result:
ok 100000 tokens
Test #13:
score: 0
Accepted
time: 642ms
memory: 28684kb
input:
200000 199899 200000 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100 738568100...
output:
Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No...
result:
ok 100000 tokens
Test #14:
score: 0
Accepted
time: 580ms
memory: 30036kb
input:
200000 199990 200000 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491 748167491...
output:
Yes No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No No...
result:
ok 100000 tokens
Test #15:
score: 0
Accepted
time: 218ms
memory: 29848kb
input:
200000 200000 200000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000...
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 200000 tokens
Test #16:
score: 0
Accepted
time: 235ms
memory: 29088kb
input:
200000 200000 200000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000...
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 200000 tokens
Test #17:
score: 0
Accepted
time: 388ms
memory: 29820kb
input:
200000 200000 200000 136241709 121069654 74104428 402269028 289305416 855066384 59173243 188019353 669781180 986996513 504339812 329791320 25125974 222565943 288337442 964609791 466878029 264002600 189175389 9157365 469615339 896075603 753652692 122288279 240727003 784469217 906985969 890794301 2169...
output:
result:
ok 0 tokens
Test #18:
score: 0
Accepted
time: 375ms
memory: 29304kb
input:
200000 200000 200000 273240622 378627620 579491720 693306037 632472065 511340335 670989889 554488479 652467925 278524470 836147563 424777678 759339952 855362660 230757613 865543002 560326470 755302163 785969817 6168093 585297358 945522008 799833815 740595138 24393108 602846463 227643614 845760733 81...
output:
result:
ok 0 tokens
Test #19:
score: 0
Accepted
time: 379ms
memory: 28408kb
input:
200000 200000 200000 902784461 118694875 998774623 411874728 685597851 368044897 72498166 42228570 960589282 760858636 63223215 20140256 256927497 432494553 374529608 902188891 898994 969710880 697644219 743838599 684197754 515142816 492082738 409457048 326043554 219156706 376310102 878117528 358651...
output:
result:
ok 0 tokens
Test #20:
score: 0
Accepted
time: 494ms
memory: 28980kb
input:
200000 200000 200000 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584 658243584...
output:
Yes No Yes No Yes No No No Yes No No No No No No No Yes No Yes Yes No No Yes No No No No No Yes Yes No No No No Yes No Yes No Yes No Yes No Yes No No No No No No No Yes No No No No No Yes No No No Yes No Yes No Yes No Yes No Yes No No No No No Yes No No No No Yes Yes No Yes No Yes No Yes No No No Ye...
result:
ok 100000 tokens
Test #21:
score: -100
Wrong Answer
time: 386ms
memory: 29436kb
input:
194304 200000 200000 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896 959184896...
output:
1 194304 8096 Yes 24289 186208 8096 Yes 8097 194304 8096 Yes 1 194304 8096 Yes 8097 170016 8096 Yes 8097 186208 8096 Yes 16193 178112 8096 Yes 8097 194304 8096 Yes 24289 178112 8096 Yes 16193 178112 8096 Yes 1 194304 8096 Yes 16193 170016 8096 Yes 8097 186208 8096 Yes 1 178112 8096 Yes 24289 178112 ...
result:
wrong answer 1st words differ - expected: 'Yes', found: '1'