QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#741096 | #9543. Good Partitions | CSQ# | WA | 3ms | 6256kb | C++17 | 1.2kb | 2024-11-13 13:19:37 | 2024-11-13 13:19:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
int gcd(int a,int b){
if(!b)return a;
if(!a)return b;
return gcd(b,a%b);
}
const int MAXN = 2e5;
int t[4*MAXN];
void build(int v,int l,int r){
t[v] = 0;
if(l==r)return;
int tm = (l+r)/2;
build(2*v,l,tm);
build(2*v+1,tm+1,r);
}
void upd(int v,int l,int r,int pos,int val){
if(l==r){
t[v] = val;
return;
}
int tm = (l+r)/2;
if(pos <= tm)upd(2*v,l,tm,pos,val);
else upd(2*v+1,tm+1,r,pos,val);
t[v] = gcd(t[2*v],t[2*v+1]);
}
int d[MAXN];
int main()
{
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
for(int i=1;i<MAXN;i++){
for(int j=i;j<MAXN;j+=i){
d[j]++;
}
}
int tc;
cin>>tc;
while(tc--){
int n,q;
cin>>n>>q;
vector<int>a(n);
for(int i=1;i<=n;i++)cin>>a[i];
build(1,1,n);
for(int i=1;i<n;i++){
if(a[i] > a[i+1])upd(1,1,n,i,i);
}
cout<<d[t[1]]<<'\n';
while(q--){
int p,v;
cin>>p>>v;
a[p] = v;
if(p-1){
if(a[p-1] > a[p])upd(1,1,n,p-1,p-1);
else upd(1,1,n,p-1,0);
}
if(p+1<=n){
if(a[p] > a[p+1])upd(1,1,n,p,p);
else upd(1,1,n,p,0);
}
cout<<d[t[1]]<<'\n';
}
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 4232kb
input:
1 5 2 4 3 2 6 1 2 5 3 5
output:
1 2 3
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 6256kb
input:
1 1 1 2000000000 1 1999999999
output:
0 0
result:
wrong answer 1st lines differ - expected: '1', found: '0'