ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214810 | #2647. interval | stawalr | 10 | 3293ms | 13236kb | C++ | 1.6kb | 2024-11-21 22:12:38 | 2024-11-22 09:37:16 |
answer
#include<iostream>
#include<cstdio>
#define lc (p<<1)
#define rc (p<<1|1)
#define mid ((s+t)>>1)
#define int long long
using namespace std;
const int mn=500005;
int n,m;
int gcd(int x,int y)
{
return (y==0)?x:gcd(y,x%y);
}
int b[mn<<2],a[mn];
void pup(int p)
{
b[p]=gcd(b[lc],b[rc]);
}
void build(int s,int t,int p)
{
if(s==t)
{
b[p]=a[s];
return;
}
build(s,mid,lc);
build(mid+1,t,rc);
pup(p);
}
void upd(int x,int c,int s,int t,int p)
{
if(s==t)
{
b[p]=c;
return;
}
if(x<=mid)upd(x,c,s,mid,lc);
else upd(x,c,mid+1,t,rc);
pup(p);
}
int qry(int l,int r,int x,int s,int t,int p)
{
if(s==t && b[p]%x!=0)return 1;
if(b[p]%x==0)
{
// cerr<<"yep";
return 0;
}
int res=0;
if(b[lc]%x!=0 && b[rc]%x!=0)return 0x3f;
if(l<=mid)res+=qry(l,r,x,s,mid,lc);
if(res>1)return 0x3f;
if(r>mid)res+=qry(l,r,x,mid+1,t,rc);
if(res>1)return 0x3f;
// cerr<<s<<" "<<t<<" "<<res<<'\n';
return res;
}
signed main()
{
int op,l,r,x,c;
scanf("%lld",&n);
for(int i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
}
scanf("%lld",&m);
build(1,n,1);
for(int i=1;i<=m;i++)
{
scanf("%lld",&op);
if(op==1)
{
scanf("%lld%lld%lld",&l,&r,&x);
// cerr<<(qry(l,r,x,1,n,1))<<'\n';
if(qry(l,r,x,1,n,1)>1)printf("NO\n");
else printf("YES\n");
}
else
{
scanf("%lld%lld",&x,&c);
upd(x,c,1,n,1);
}
}
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 1344kb
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 NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO...
result:
wrong answer 3rd lines differ - expected: 'YES', found: 'NO'
Test #2:
score: 0
Wrong Answer
time: 3ms
memory: 1344kb
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 NO NO YES 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 N...
result:
wrong answer 4th lines differ - expected: 'YES', found: 'NO'
Test #3:
score: 0
Wrong Answer
time: 438ms
memory: 13228kb
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:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO N...
result:
wrong answer 4th lines differ - expected: 'YES', found: 'NO'
Test #4:
score: 0
Wrong Answer
time: 425ms
memory: 13100kb
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:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO N...
result:
wrong answer 9th lines differ - expected: 'YES', found: 'NO'
Test #5:
score: 0
Wrong Answer
time: 391ms
memory: 13228kb
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:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO N...
result:
wrong answer 34th lines differ - expected: 'YES', found: 'NO'
Test #6:
score: 0
Wrong Answer
time: 405ms
memory: 13104kb
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:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO N...
result:
wrong answer 1st lines differ - expected: 'YES', found: 'NO'
Test #7:
score: 0
Wrong Answer
time: 419ms
memory: 12976kb
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:
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 ...
result:
wrong answer 38th lines differ - expected: 'YES', found: 'NO'
Test #8:
score: 0
Wrong Answer
time: 426ms
memory: 13236kb
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:
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 NO NO NO NO NO...
result:
wrong answer 51st lines differ - expected: 'YES', found: 'NO'
Test #9:
score: 0
Wrong Answer
time: 406ms
memory: 13144kb
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:
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 NO NO NO NO...
result:
wrong answer 79872nd lines differ - expected: 'YES', found: 'NO'
Test #10:
score: 10
Accepted
time: 377ms
memory: 12888kb
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:
NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO N...
result:
ok 227345 lines