QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#555381#3101. Event Hopping 2cocoa_chan0 161ms105932kbC++173.8kb2024-09-09 22:16:462024-09-09 22:16:46

Judging History

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

  • [2024-09-09 22:16:46]
  • 评测
  • 测评结果:0
  • 用时:161ms
  • 内存:105932kb
  • [2024-09-09 22:16:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll siz=262144;
const ll inf=1e18;
ll n,m,i,j,k,l,r,x,y,z,w,s,t,a[1100000],seg[1100000],lazy[1100000],e,ee,sparse[31][220000],cur,mn,asdf,ans[1100000];
set<ll> le,ri;
pair<ll,ll> p[1100000],q[1100000];
vector<ll> u,v[1100000];
void propagate(ll x,ll y,ll z)
{
    if(z<siz)
    {
        lazy[z*2]+=lazy[z];
        lazy[z*2+1]+=lazy[z];
    }
    seg[z]+=lazy[z];
    lazy[z]=0;
}
void f(ll x,ll y,ll z,ll w)
{
    propagate(x,y,z);
    if(l>y||x>r)
        return;
        if(l<=x&&y<=r)
        {
            lazy[z]+=w;
            propagate(x,y,z);
            return;
        }
    f(x,(x+y)/2,z*2,w);
    f((x+y)/2+1,y,z*2+1,w);
    seg[z]=seg[z*2]+seg[z*2+1];
}
ll g(ll x,ll y,ll z)
{
    propagate(x,y,z);
    if(l>y||x>r)
        return 0;
    if(l<=x&&y<=r)
        return seg[z];
    return g(x,(x+y)/2,z*2)+g((x+y)/2+1,y,z*2+1);
}
ll interval(ll x,ll y)
{
    ll e=30,s=0;
    while(e>=0)
    {
        if(sparse[e][x]<=y)
        {
            s+=1<<e;
           // printf("(%lld:%lld,%lld)",x,e,sparse[e][x]);
            x=sparse[e][x]+1;
        }
        e--;
    }
    return s;
}
ll inthere(ll x,ll y)
{
    l=x;
    r=y;
    return g(1,siz,1);
}
ll prv(ll x)
{
    return *(--ri.lower_bound(x));
}
ll nxt(ll x)
{
    printf("[%lld:%lld]\n",x,*(le.lower_bound(x+1)));
    return *(le.lower_bound(x+1));
}
void add(ll x,ll y)
{
    le.insert(x);
    ri.insert(y);
    l=x;
    r=y;
    f(1,siz,1,1);
}
int main()
{

    scanf("%lld %lld",&n,&k);
    le.insert(2*n+3);
    ri.insert(0);
    for(i=1;i<=n;i++)
    {
        scanf("%lld %lld",&x,&y);
        y--;
        u.push_back(x);
        u.push_back(y);
        p[i]={x,y};
    }
    sort(u.begin(),u.end());
    u.erase(unique(u.begin(),u.end()),u.end());
    for(i=1;i<=n;i++)
    {
        p[i].first=lower_bound(u.begin(),u.end(),p[i].first)-u.begin()+2;
        p[i].second=lower_bound(u.begin(),u.end(),p[i].second)-u.begin()+2;
        x=p[i].first;
        y=p[i].second;
        q[i]={y,x};
    }
    sort(q+1,q+n+1);
    for(i=1;i<=n;i++)
        swap(q[i].first,q[i].second);
    for(i=1;i<=n;i++)
    {
     //   printf("(%lld,%lld)\n",q[i].first,q[i].second);
    }
    for(i=1;i<=n;i++)
    {
        v[q[i].first].push_back(i);
    }
    mn=2*n+4;
    cur=2*n+4;
    q[2*n+4]={2*n+3,2*n+3};
    sparse[0][2*n+4]=2*n+4;
    q[0]={1,1};
    for(i=n*2+3;i>=1;i--)
    {
        x=i;
        for(auto xx:v[i+1])
        {
            if(mn>q[xx].second)
            {
                mn=q[xx].second;
                cur=xx;
            }
        }
     //   printf("(%lld:%lld)\n",i,cur);
        sparse[0][i]=mn;
    }
    /*for(i=1;i<=2*n+4;i++)
        printf("(%lld)",sparse[e][i]);
    printf("\n");
    */for(e=1;e<=30;e++)
    {
        for(i=1;i<=n*2+4;i++)
        {
            sparse[e][i]=sparse[e-1][min(sparse[e-1][i],2*n+4)];
      //      printf("(%lld)",sparse[e][i]);
        }
       // printf("\n");
    }
    //printf("?");
    if(interval(1,2*n+2)<k)
    {
   //     printf("(%lld)",interval(1,2*n+2));
        printf("-1");
        return 0;
    }
    m=k;
    t=interval(1,2*n+2);
    //printf("%lld\n",t);
    cur=0;
    for(i=1;i<=n;i++)
    {
      //  printf("(%lld)\n",i);
        x=p[i].first;
        y=p[i].second;
        if(inthere(x,y))
            continue;
        z=prv(x);
        w=nxt(y);
        //printf("(%lld,%lld,%lld,%lld,%lld,%lld)",z+1,w-1,z+1,x-1,y+1,w-1);
        asdf=-interval(z+1,w-1)+interval(z+1,x-1)+interval(y+1,w-1);
        s=t+asdf+cur;
        if(s>=k)
        {
            t+=asdf;
            cur++;
            ans[cur]=i;
            add(x,y);
        }
    }
    for(i=1;i<=k;i++)
    {
        printf("%lld\n",ans[i]);
    }
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 8ms
memory: 91084kb

input:

1 1
1 3

output:

[3:5]
0

result:

wrong answer 1st lines differ - expected: '1', found: '[3:5]'

Subtask #2:

score: 0
Wrong Answer

Test #47:

score: 0
Wrong Answer
time: 4ms
memory: 93040kb

input:

1 1
134842099 137944073

output:

[3:5]
0

result:

wrong answer 1st lines differ - expected: '1', found: '[3:5]'

Subtask #3:

score: 0
Wrong Answer

Test #74:

score: 0
Wrong Answer
time: 3ms
memory: 92088kb

input:

3000 57
226083340 261990234
392684356 462929590
468018811 841719892
495096853 606046097
196983814 256423598
331199122 967656486
802593662 931108452
74501453 679054962
294344294 752837262
295708332 547261648
265421699 652708933
272959087 727136240
165667761 846917534
61770748 157663302
608516043 8492...

output:

[1580:6003]
[2772:6003]
[5031:6003]
[3654:6003]
[1532:6003]
[5792:6003]
[5582:6003]
[4099:6003]
[4509:6003]
[3285:6003]
[3926:6003]
[4347:6003]
[5059:6003]
[937:6003]
[5073:6003]
[4599:6003]
[2186:6003]
[1977:6003]
[4242:6003]
[4690:6003]
[2556:6003]
[4102:6003]
[5966:6003]
[2598:6003]
[5587:6003]
[...

result:

wrong answer 1st lines differ - expected: '50', found: '[1580:6003]'

Subtask #4:

score: 0
Wrong Answer

Test #111:

score: 0
Wrong Answer
time: 161ms
memory: 105932kb

input:

100000 361
136798318 785362988
255943758 535488232
175203444 266819907
766993466 893575347
67274251 589651108
662289594 883406317
830803801 849703610
729398668 798198453
202605534 677648797
66407931 925909114
174421361 601553812
522629146 701284080
136544340 295925673
299796891 499869765
736583725 8...

output:

[157116:200003]
[107208:200003]
[53673:200003]
[178674:200003]
[117974:200003]
[176608:200003]
[169899:200003]
[159675:200003]
[135646:200003]
[185111:200003]
[120386:200003]
[140403:200003]
[59490:200003]
[100135:200003]
[164487:200003]
[116714:200003]
[188179:200003]
[153584:200003]
[139624:200003...

result:

wrong answer 1st lines differ - expected: '42', found: '[157116:200003]'