QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#741096#9543. Good PartitionsCSQ#WA 3ms6256kbC++171.2kb2024-11-13 13:19:372024-11-13 13:19:38

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 13:19:38]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:6256kb
  • [2024-11-13 13:19:37]
  • 提交

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'