ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#214766 | #2647. interval | ThySecret | 0 | 72ms | 2108kb | C++11 | 3.0kb | 2024-11-21 19:24:55 | 2024-11-22 09:31:44 |
answer
#include <bits/stdc++.h>
using namespace std;
// #define int long long
// #define x first
// #define y second
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
inline void debug() { cerr << '\n'; }
template<typename Type, typename... Other>
inline void debug(const Type& x, const Other&... y) { cerr << x << ' '; debug(y...); }
#define DEBUG(a...) cerr << "[" << #a << "] = ", debug(a);
typedef long long LL;
typedef pair<int, int> PII;
const int N = 200010;
const int INF = 0x3f3f3f3f;
template<typename Type>
inline void read(Type &res)
{
res = 0;
int ch = getchar(), flag = 0;
while (!isdigit(ch)) flag |= ch == '-', ch = getchar();
while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
res = flag ? -res : res;
}
template<typename Type, typename... Other>
inline void read(Type &res, Other&... y) { read(res), read(y...); }
int n, m, a[N];
struct SegsTree
{
#define lc u << 1
#define rc u << 1 | 1
struct Node { int l, r, gcd; } tr[N << 2];
inline void pushup(int u) { tr[u].gcd = __gcd(tr[lc].gcd, tr[rc].gcd); }
void build(int u, int l, int r)
{
tr[u].l = l, tr[u].r = r;
if (l == r) return tr[u].gcd = a[l], void();
int mid = l + r >> 1;
build(lc, l, mid), build(rc, mid + 1, r);
pushup(u);
}
void modify(int u, int x, int k)
{
if (tr[u].l == tr[u].r)
return tr[u].gcd = k, void();
int mid = tr[u].l + tr[u].r >> 1;
modify(u << 1 | (x > mid), x, k);
pushup(u);
}
int query(int u, int l, int r)
{
if (l <= tr[u].l && tr[u].r <= r)
return tr[u].gcd;
int mid = tr[u].l + tr[u].r >> 1, res = 0;
if (l <= mid) res = query(lc, l, r);
if (r > mid) res = __gcd(res, query(rc, l, r));
return res;
}
bool find(int u, int l, int r, int k)
{
if (tr[u].l == tr[u].r) return true;
if (l <= tr[u].l && tr[u].r <= r)
{
if (tr[u].gcd % k != 0)
{
if (tr[lc].gcd % k != 0 && tr[rc].gcd % k == 0)
return find(lc, l, r, k);
else if (tr[lc].gcd % k == 0 && tr[rc].gcd % k != 0)
return find(rc, l, r, k);
else return false;
}
else return true;
}
int mid = tr[u].l + tr[u].r >> 1, res = true;
if (l <= mid) res &= find(lc, l, r, k);
if (r > mid) res &= find(rc, l, r, k);
return res;
}
} SGT;
signed main()
{
read(n);
for (int i = 1; i <= n; i ++) read(a[i]);
SGT.build(1, 1, n);
read(m);
int opt, x, y, k;
while (m --)
{
read(opt, x, y);
if (opt == 1)
{
read(k);
cout << (SGT.find(1, x, y, k) ? "YES" : "NO") << '\n';
}
else SGT.modify(1, x, y);
}
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 1356kb
input:
4794 52 364 910 468 13650 728 72 5 75 546 273 468 60 360 585 60 175 315 20475 350 18200 18 900 100 4...
output:
NO NO YES NO NO NO NO NO NO NO NO NO YES NO YES YES NO YES NO NO NO NO YES NO YES NO NO NO NO NO NO ...
result:
wrong answer 33rd lines differ - expected: 'NO', found: 'YES'
Test #2:
score: 0
Wrong Answer
time: 2ms
memory: 1356kb
input:
4601 117 42 16380 40 6300 84 18200 468 1820 30 4095 2520 2925 840 6552 900 78 273 450 3900 4680 6300...
output:
NO YES NO YES NO YES NO NO NO NO NO NO NO NO NO NO YES YES NO NO NO NO NO NO YES YES YES NO NO YES N...
result:
wrong answer 26th lines differ - expected: 'NO', found: 'YES'
Test #3:
score: 0
Wrong Answer
time: 7ms
memory: 2108kb
input:
493909 2340 163800 455 24 1638 130 14 1 182 4200 40 225 600 140 728 936 21 25 81900 520 1800 3 130 6...
output:
result:
wrong answer 1st lines differ - expected: 'NO', found: ''
Test #4:
score: 0
Wrong Answer
time: 8ms
memory: 1944kb
input:
477523 650 9 390 40950 39 1300 5850 600 1638 2184 936 260 16380 3900 1300 12600 11700 546 5 168 14 2...
output:
result:
wrong answer 1st lines differ - expected: 'NO', found: ''
Test #5:
score: 0
Wrong Answer
time: 13ms
memory: 1924kb
input:
494330 7800 56 20 364 36 150 910 4550 780 280 936 163800 1400 8 130 56 936 700 84 14 450 325 650 360...
output:
YES YES YES YES NO YES YES YES YES NO YES YES YES NO NO YES YES NO YES YES YES NO NO NO NO YES YES Y...
result:
wrong answer 1st lines differ - expected: 'NO', found: 'YES'
Test #6:
score: 0
Wrong Answer
time: 5ms
memory: 1928kb
input:
477944 2184 182 105 75 42 3276 36 390 16380 2600 105 10 780 163800 21 504 182 312 13650 650 6552 234...
output:
YES YES NO NO YES YES YES YES YES NO YES YES NO NO YES YES YES YES YES YES YES YES YES YES YES YES Y...
result:
wrong answer 2nd lines differ - expected: 'NO', found: 'YES'
Test #7:
score: 0
Wrong Answer
time: 8ms
memory: 1928kb
input:
461558 5460 36 2340 180 15 819 156 117 210 72 819 312 546 40 300 12600 200 1170 360 105 52 3 175 292...
output:
YES YES
result:
wrong answer 1st lines differ - expected: 'NO', found: 'YES'
Test #8:
score: 0
Wrong Answer
time: 10ms
memory: 1948kb
input:
495172 3900 6552 280 6825 35 630 18200 2275 1638 16380 210 45 75 2184 210 975 30 4 100 15 105 100 84...
output:
YES YES YES YES YES YES YES NO
result:
wrong answer 1st lines differ - expected: 'NO', found: 'YES'
Test #9:
score: 0
Wrong Answer
time: 9ms
memory: 2024kb
input:
483384 27300 16380 350 200 364 84 210 1 35 6825 910 30 390 504 52 504 1575 350 315 4550 6825 18200 9...
output:
YES
result:
wrong answer 1st lines differ - expected: 'NO', found: 'YES'
Test #10:
score: 0
Wrong Answer
time: 9ms
memory: 1924kb
input:
450191 20475 910 900 39 3 234 40950 3276 11700 175 50 140 1300 15 26 200 18 16380 180 7800 4680 4095...
output:
YES YES NO
result:
wrong answer 1st lines differ - expected: 'NO', found: 'YES'