ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#214768 | #2647. interval | erican | 20 | 3ms | 1296kb | C++11 | 2.9kb | 2024-11-21 19:40:05 | 2024-11-22 09:31:54 |
answer
/* Erica N */
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define ull unsigned long long
#define pii pair<int, int>
#define ps second
#define pf first
#define itn int
#define rd read()
int read(){
int xx = 0, ff = 1;char ch = getchar();
while (ch < '0' || ch > '9') {if (ch == '-')ff = -1; ch = getchar();}
while (ch >= '0' && ch <= '9')xx = xx * 10 + (ch - '0'), ch = getchar();
return xx * ff;
}
// void write(int out) {
// if (out < 0)
// putchar('-'), out = -out;
// if (out > 9)
// write(out / 10);
// putchar(out % 10 + '0');
// }
#define cdbg(x...) do { cerr << #x << " -> "; err(x); } while (0)
void err() { cerr << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cerr << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
const int N = 3e5 + 5;
const int INF = 1e18;
const int M = 1e7;
const int MOD = 1e9 + 7;
int a[N];
namespace SGT{
int t[N<<2];
void pushup(int x){
t[x]=__gcd(t[x<<1],t[x<<1|1]);
}
void change(int x,int l,int r,int p,int v){
if(l==r)return t[x]=v,void();
int mid=l+r>>1;
if(p<=mid)change(x<<1,l,mid,p,v);
else change(x<<1|1,mid+1,r,p,v);
pushup(x);
}
int queryl(int x,int l,int r,int p,int v){
// cdbg(l,r,t[x]);
if(t[x]%v==0)return INF;
if(l==r){
return t[x]%v==0?INF:l-1;
}
int mid=l+r>>1;
int res=INF;
if(p<=mid)res=min(res,queryl(x<<1,l,mid,p,v));
if(res==INF)res=min(res,queryl(x<<1|1,mid+1,r,p,v));
return res;
}
int queryr(int x,int l,int r,int p,int v){
if(t[x]%v==0)return 0;
if(l==r){
return t[x]%v==0?0:l+1;
}
int mid=l+r>>1;
int res=0;
if(p>mid)res=max(res,queryr(x<<1|1,mid+1,r,p,v));
if(res==0)res=max(res,queryr(x<<1,l,mid,p,v));
return res;
}
void build(int x,int l,int r){
if(l==r)return t[x]=a[l],void ();
int mid=l+r>>1;
build(x<<1,l,mid);
build(x<<1|1,mid+1,r);
pushup(x);
}
}using namespace SGT;
signed main() {
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
int n=rd;
for(int i=1;i<=n;i++){
a[i]=rd;
}
build(1,1,n);
int q=rd;
while(q--){
int op=rd;
if(op==1){
int l=rd,r=rd,x=rd;
int L=queryl(1,1,n,l,x);
int R=queryr(1,1,n,r,x);
// cdbg(L,R);
if(L>=R-2)puts("YES");
else puts("NO");
}else{
int x=rd,v=rd;
change(1,1,n,x,v);
}
}
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 3ms
memory: 1296kb
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:
ok 2239 lines
Test #2:
score: 10
Accepted
time: 0ms
memory: 1296kb
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 NO YES NO NO YES NO...
result:
ok 2466 lines
Test #3:
score: 0
Runtime Error
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:
Test #4:
score: 0
Runtime Error
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:
Test #5:
score: 0
Runtime Error
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:
result:
Test #6:
score: 0
Runtime Error
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:
result:
Test #7:
score: 0
Runtime Error
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:
result:
Test #8:
score: 0
Runtime Error
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:
result:
Test #9:
score: 0
Runtime Error
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:
result:
Test #10:
score: 0
Runtime Error
input:
450191 20475 910 900 39 3 234 40950 3276 11700 175 50 140 1300 15 26 200 18 16380 180 7800 4680 4095...