Submission #977823

# Submission time Handle Problem Language Result Execution time Memory
977823 2024-05-08T11:29:06 Z De3b0o Bridges (APIO19_bridges) C++14
0 / 100
569 ms 5972 KB
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)

using namespace std;

ll fp(ll x , ll y)
{
    if(y==0)
        return 1;
    ll z = fp(x,y/2);
    if(y&1)
        return z*z%mod*x%mod;
    else
        return z*z%mod;
}

int sqrot(ll x)
{
    int l = 0 , r = INT_MAX;
    while(l<=r)
    {
        if(mid*mid>=x)
            r=mid-1;
        else
            l=mid+1;
    }
    return r+1;
}

ll cel(ll x , ll y)
{
    return x/y + bool(x%y);
}

ll n , m;
ll val[100009];
ll ans;
ll seg[400009];

void sb(ll n , ll l , ll r)
{
    if(l==r)
    {
        seg[n]=val[l];
        return;
    }
    sb(lc,l,mid);
    sb(rc,mid+1,r);
    seg[n]=min(seg[lc],seg[rc]);
}

void se(ll n , ll l , ll r , ll idx , ll w)
{
    if(l>idx||r<idx)
        return;
    if(l==r)
    {
        seg[n]=w;
        return;
    }
    se(lc,l,mid,idx,w);
    se(rc,mid+1,r,idx,w);
    seg[n]=min(seg[lc],seg[rc]);
}

ll sg(ll n , ll l , ll r , ll l1 , ll r1)
{
    if(l>r1||r<l1)
        return 1e10;
    if(l>=l1&&r<=r1)
        return seg[n];
    return min(sg(lc,l,mid,l1,r1),sg(rc,mid+1,r,l1,r1));
}

int main()
{
    d3
    cin >> n >> m;
    for(int i = 1 ; m>=i ; i++)
    {
        ll eee;
        cin >> eee >> eee >> val[i];
    }
    sb(1,1,n-1);
    ll q;
    cin >> q;
    while(q--)
    {
        ll t;
        cin >> t;
        if(t==1)
        {
            ll idx , w;
            cin >> idx >> w;
            se(1,1,n-1,idx,w);
        }
        else
        {
            ll idx , w;
            cin >> idx >> w;
            ll ans = 1;
            ll l = idx , r = n-1;
            ll y = idx-1;
            while(l<=r)
            {
                ll x = sg(1,1,n-1,idx,mid);
                if(x>=w)
                {
                    y=mid;
                    l=mid+1;
                }
                else
                    r=mid-1;
            }
            ans+=y-(idx-1);
            l = 1 , r = idx-1;
            y=idx;
            while(l<=r)
            {
                ll x = sg(1,1,n-1,mid,idx);
                if(x>=w)
                {
                    y=mid;
                    r=mid-1;
                }
                else
                    l=mid+1;
            }
            ans+=idx-y;
            cans
        }
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 472 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 301 ms 4944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 298 ms 4632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 569 ms 5972 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 301 ms 4944 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 472 KB Output isn't correct
2 Halted 0 ms 0 KB -