Submission #863305

# Submission time Handle Problem Language Result Execution time Memory
863305 2023-10-20T02:44:52 Z ibm2006 Meteors (POI11_met) C++17
74 / 100
5589 ms 65536 KB
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx")
using namespace std;
typedef long long int ll;
typedef __int128 lll;
ll x,z,w,lazy[1048576];
int le[300030],ri[300030],q,i,j,k,n,s,e,a[300030],l,r,m;
ll te1,te2,te3;
ll seg[1048576],y;
vector<int> v[300030],u[300030];
pair<pair<int,int>,ll> upd[300030];
void h(ll x,ll y,ll z)
{
    if(lazy[z]==0)
        return;
    if(z>=524288)
    {
        seg[z]+=lazy[z];
        lazy[z]=0;
        return;
    }
    seg[z]+=(y-x+1)*lazy[z];
    lazy[z<<1]+=lazy[z];
    lazy[(z<<1)+1]+=lazy[z];
    lazy[z]=0;
    return;
}
void Clear()
{
    ll i;
    for(i=0;i<1048576;i++)
    {
        seg[i]=0;
        lazy[i]=0;
    }
}
void f(ll x,ll y,ll z,ll w)
{
    h(x,y,z);
    if(l>y||x>r)
        return;
    if(l<=x&&y<=r)
    {
        lazy[z]+=w;
        h(x,y,z);
        return;
    }
    f(x,(x+y)>>1,z<<1,w);
    f(((x+y)>>1)+1,y,(z<<1)+1,w);
    seg[z]=seg[z<<1]+seg[(z<<1)+1];
}
ll g(ll x,ll y,ll z)
{
    h(x,y,z);
    if(l>y||x>r)
        return 0;
    if(l<=x&&y<=r)
    {
        return seg[z];
    }
    return g(x,(x+y)>>1,z<<1)+g(((x+y)>>1)+1,y,(z<<1)+1);
}
int main()
{
    scanf("%lld %lld",&te1,&te2);
    n=te1;
    m=te2;
    for(i=1;i<=m;i++)
    {
        scanf("%lld",&te1);
        x=te1;
        //x=1;
        v[x].push_back(i);
    }
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&te1);
        a[i]=te1;
    //a[i]=1e9;
    }
    scanf("%lld",&te1);
    q=te1;
    for(i=1;i<=q;i++)
    {
        scanf("%lld %lld %lld",&te1,&te2,&te3);
        x=te1;
        w=te2;
        z=te3;
        //x=1;  w=m;  z=1;
        upd[i]={{x,w},z};
    }
    for(i=1;i<=n;i++)
    {
        le[i]=1;
        ri[i]=q+1;
    }
    for(e=0;e<19;e++)
    {
        //printf("!");
        //for(i=1;i<=n;i++)
          //  printf("(%lld,%lld)\n",le[i],ri[i]);
        Clear();
        s=1;
        for(i=1;i<=q+1;i++)
        {
            u[i].clear();
        }
        for(i=1;i<=n;i++)
            u[(le[i]+ri[i])>>1].push_back(i);
        for(i=1;i<=q+1;i++)
        {
            //printf("%lld\n",i);
            if(i<=q)
            {x=upd[i].first.first;
            y=upd[i].first.second;
            z=upd[i].second;
            if(x<=y)
            {
                l=x;
                r=y;
                f(1,524288,1,z);
            }
            else
            {
                l=x;
                r=m;
                f(1,524288,1,z);
                l=1;
                r=y;
                f(1,524288,1,z);
            }
            }
            //printf("?");
            for(j=0;j<u[i].size();j++)
            {
                x=u[i][j];
                y=0;
                for(k=0;k<v[x].size();k++)
                {
                l=v[x][k];
                r=v[x][k];
                y+=g(1,524288,1);
                if(a[x]<=y)
                    break;
                }
                if(a[x]<=y)
                {
                    ri[x]=i;
                }
                else
                    le[x]=i+1;
                    le[x]=min(le[x],q+1);
       // printf("[%lld,%lld]\n",(le[x]+ri[x])/2,x);
                //p[s]={(le[x]+ri[x])/2,x};
                s++;

            }
        }
        //swap(p,pp);
    }
    for(i=1;i<=n;i++)
    {
        a[i]=le[i];
    }
    for(i=1;i<=n;i++)
    {
        te1=a[i];
        if(a[i]>=q+1)
        {
            printf("NIE\n");
        }
        else
            printf("%lld\n",te1);
    }
}

Compilation message

met.cpp: In function 'int main()':
met.cpp:135:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  135 |             for(j=0;j<u[i].size();j++)
      |                     ~^~~~~~~~~~~~
met.cpp:139:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  139 |                 for(k=0;k<v[x].size();k++)
      |                         ~^~~~~~~~~~~~
met.cpp:151:17: warning: this 'else' clause does not guard... [-Wmisleading-indentation]
  151 |                 else
      |                 ^~~~
met.cpp:153:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'else'
  153 |                     le[x]=min(le[x],q+1);
      |                     ^~
met.cpp:66:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |     scanf("%lld %lld",&te1,&te2);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
met.cpp:71:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         scanf("%lld",&te1);
      |         ~~~~~^~~~~~~~~~~~~
met.cpp:78:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   78 |         scanf("%lld",&te1);
      |         ~~~~~^~~~~~~~~~~~~
met.cpp:82:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   82 |     scanf("%lld",&te1);
      |     ~~~~~^~~~~~~~~~~~~
met.cpp:86:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   86 |         scanf("%lld %lld %lld",&te1,&te2,&te3);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 26 ms 34904 KB Output is correct
2 Correct 29 ms 34928 KB Output is correct
3 Correct 36 ms 34908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 32 ms 34932 KB Output is correct
2 Correct 33 ms 34908 KB Output is correct
3 Correct 31 ms 34908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 524 ms 37708 KB Output is correct
2 Correct 796 ms 39516 KB Output is correct
3 Correct 742 ms 39380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 711 ms 38908 KB Output is correct
2 Correct 722 ms 38848 KB Output is correct
3 Correct 749 ms 39532 KB Output is correct
4 Correct 208 ms 36432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 336 ms 38320 KB Output is correct
2 Correct 488 ms 40140 KB Output is correct
3 Correct 384 ms 37204 KB Output is correct
4 Correct 688 ms 39508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 685 ms 37672 KB Output is correct
2 Correct 605 ms 38740 KB Output is correct
3 Correct 641 ms 37704 KB Output is correct
4 Correct 764 ms 40720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5170 ms 51652 KB Output is correct
2 Correct 1839 ms 40632 KB Output is correct
3 Correct 1848 ms 39248 KB Output is correct
4 Runtime error 5589 ms 65536 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5163 ms 50428 KB Output is correct
2 Correct 1210 ms 40352 KB Output is correct
3 Correct 1448 ms 39276 KB Output is correct
4 Runtime error 4909 ms 65536 KB Execution killed with signal 9
5 Halted 0 ms 0 KB -