QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#722341 | #9543. Good Partitions | xh_team# | WA | 94ms | 21648kb | C++20 | 1.8kb | 2024-11-07 18:40:05 | 2024-11-07 18:40:05 |
Judging History
answer
#pragma GCC optimize("Ofast,unroll-loops")
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using i64=long long;
#define int ll
const int N=2e5+10,mod=1e9+7;
ll qpow(ll a,ll b,ll p){ll res=1;for(;b;b>>=1,a=a*a%p)if(b&1)res=res*a%p;return res;}
int n,m;
int a[N];
int ans[N];
int sum[N];
struct node{
int l,r;
int d;
}tr[N*4];
void pushup(node &u,node l,node r){
u.d=__gcd(l.d,r.d);
}
void pushup(int u){
pushup(tr[u],tr[u<<1],tr[u<<1|1]);
}
void build(int u,int l,int r){
tr[u].l=l,tr[u].r=r;
tr[u].d=0;
if(l==r){
return;
}
int mid=l+r>>1;
build(u<<1,l,mid);
build(u<<1|1,mid+1,r);
}
void modify(int u,int x){
if(tr[u].l==tr[u].r){
tr[u].d=ans[tr[u].l];
return;
}
int mid=tr[u].l+tr[u].r>>1;
if(x<=mid) modify(u<<1,x);
else modify(u<<1|1,x);
pushup(u);
}
void solve(){
cin>>n>>m;
for(int i=1;i<=n;i++) cin>>a[i],ans[i]=0;
build(1,1,n);
for(int i=1;i<n;i++){
if(a[i]>a[i+1]) ans[i]=i;
}
if(n==1){
cout<<1<<"\n";
}else{
for(int i=1;i<=n;i++) modify(1,i);
cout<<tr[1].d<<"\n";
}
for(int i=1,x,v;i<=m;i++){
cin>>x>>v;
a[x]=v;
if(n==1){
cout<<1<<"\n";
continue;
}
if(x!=n&&a[x]>a[x+1]) ans[x]=x;
else ans[x]=0;
if(x!=1&&a[x-1]>a[x]) ans[x-1]=x-1;
else ans[x-1]=0;
modify(1,x);
if(x!=1) modify(1,x-1);
int w=tr[1].d;
cout<<sum[w]<<"\n";
}
}
signed main(){
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
for(int i=1;i<=200000;i++){
for(int j=i;j<=200000;j+=i){
sum[j]++;
}
}
int _=1;
cin>>_;
while(_--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5224kb
input:
1 5 2 4 3 2 6 1 2 5 3 5
output:
1 2 3
result:
ok 3 lines
Test #2:
score: 0
Accepted
time: 0ms
memory: 7196kb
input:
1 1 1 2000000000 1 1999999999
output:
1 1
result:
ok 2 lines
Test #3:
score: -100
Wrong Answer
time: 94ms
memory: 21648kb
input:
1 200000 200000 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...
output:
166320 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160 0 160...
result:
wrong answer 1st lines differ - expected: '160', found: '166320'