QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#427797 | #7782. Ursa Minor | zlxFTH | TL | 1160ms | 21576kb | C++14 | 1.9kb | 2024-06-01 15:50:02 | 2024-06-01 15:50:03 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int N = 2e5 + 5;
namespace BIT {
int n;
LL a[N];
void mdf(int x, LL v) {
for (int i = x; i <= n; i += i & -i) a[i] += v;
}
LL qry(int x) {
LL res = 0;
for (int i = x; i > 0; i -= i & -i) res += a[i];
return res;
}
} using BIT::mdf; using BIT::qry;
int n, m, q;
int a[N];
int st[20][N], b[N];
inline int get_gcd(int l, int r) {
int h = __lg(r - l + 1);
return __gcd(st[h][l], st[h][r - (1 << h) + 1]);
}
int main() {
cin.tie(0)->sync_with_stdio(0);
cin >> n >> m >> q;
BIT::n = n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
mdf(i, a[i]);
}
for (int i = 1; i <= m; ++i) {
cin >> b[i];
st[0][i] = b[i];
}
for (int j = 1; j <= __lg(m); ++j)
for (int i = 1; i + (1 << j) - 1 <= m; ++i)
st[j][i] = __gcd(st[j - 1][i], st[j - 1][i + (1 << j - 1)]);
while (q--) {
char op;
cin >> op;
if (op == 'U') {
int p, v;
cin >> p >> v;
mdf(p, v - a[p]);
a[p] = v;
} else {
int l1, r1, l2, r2;
cin >> l1 >> r1 >> l2 >> r2;
int A = r1 - l1 + 1, B = get_gcd(l2, r2);
LL s = qry(r1) - qry(l1 - 1);
// if (s == 74277073403) {
// int sum = 0;
// for (int i = l2; i <= r2; ++i) sum = __gcd(sum, b[i]);
// cout << sum << "\n";
// }
// cout << A << " " << s << " " << B << "\n";
B = __gcd(B, A);
if (s % B) cout << "No\n";
else {
bool ok = true;
if (B > 1) {
for (int i = l1; i < l1 + B; ++i) {
LL t = 0;
for (int j = i; j <= r1; j += B) {
t += a[j];
if (t > s / B) break;
}
if (t != s / B) {
ok = false;
break;
}
}
}
cout << (ok ? "Yes" : "No") << "\n";
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7712kb
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: 1ms
memory: 5664kb
input:
1 1 1 0 1 Q 1 1 1 1
output:
Yes
result:
ok "Yes"
Test #3:
score: 0
Accepted
time: 27ms
memory: 13956kb
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: 42ms
memory: 21576kb
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: 31ms
memory: 17156kb
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: 182ms
memory: 21036kb
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: 1160ms
memory: 21248kb
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: 236ms
memory: 19956kb
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: 356ms
memory: 20332kb
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: 167ms
memory: 20300kb
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: 110ms
memory: 20672kb
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: 96ms
memory: 20224kb
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: 103ms
memory: 20864kb
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: 100ms
memory: 20512kb
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: -100
Time Limit Exceeded
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 ...