QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#727317#9543. Good Partitionsssx#WA 3ms9952kbC++201.8kb2024-11-09 12:41:202024-11-09 12:41:20

Judging History

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

  • [2024-11-09 12:41:20]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:9952kb
  • [2024-11-09 12:41:20]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define pll pair<ll, ll>
#define ll long long
const int mod = 1e9 + 7;
const int N = 2e5 + 50;

ll n, m, tr[N * 4]; // gcd
ll a[N];

ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }
    return b?(b,a%b):a;
}

void pushup(ll u)
{
    tr[u] = gcd(tr[u * 2], tr[u * 2 + 1]);
}

void modify(ll u, ll l, ll r, ll v, ll k)
{
    if (l == r)
    {
        //cout<<l<<" "<<k<<endl;
        if (k == 0) tr[u] = 0;
        else tr[u] = l;
    }
    else
    {
        ll mid = (l + r) >> 1;
        if (v <= mid) modify(u * 2, l, mid, v, k);
        else modify(u * 2 + 1, mid + 1, r, v, k);
        pushup(u);
    }
}

int ys[N];
void solve()
{
    ll q;
    cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 0; i <= 4 * n + 10; i++) tr[i] = 0;
    //cout<<gcd(0,100)<<endl;
    for(int i=2;i<=n;i++){
        if(a[i]<a[i-1]){
            modify(1,0,200005,i-1,1);
        }
    }
    // modify(1,0,200005,2,1);
    // modify(1,0,200005,4,1);
    ll ans=tr[1];
    cout<<ys[ans]<<endl;
    int x=0,y=0;
    for(int i=0;i<q;i++){
        cin>>x>>y;
        a[x]=y;
        if(x!=1 && a[x]<a[x-1]){
            modify(1,0,200005,x-1,1);
        }
        else{
            modify(1,0,200005,x-1,0);
        }
        if(x!=n && a[x+1]<a[x]){
            modify(1,0,200005,x,1);
            
        }
        else{
            modify(1,0,200005,x,0);
        }
        ans=tr[1];
        //cout<<ans<<endl;
        cout<<ys[ans]<<endl;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll T = 1;
    cin >> T;
    for(int i=1;i<=200000;i++){
        for(int j=0;i*j<200000;j++){
            ys[i*j]++;
        }
    }
    while (T --)
    {
        solve();
    }
    
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 9952kb

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: 8576kb

input:

1
1 1
2000000000
1 1999999999

output:

200000
200000

result:

wrong answer 1st lines differ - expected: '1', found: '200000'