QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#875736#7335. EvacuationwoshiSB_riverWA 285ms12704kbC++145.8kb2025-01-30 11:23:292025-01-30 11:23:29

Judging History

This is the latest submission verdict.

  • [2025-01-30 11:23:29]
  • Judged
  • Verdict: WA
  • Time: 285ms
  • Memory: 12704kb
  • [2025-01-30 11:23:29]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
inline int read()
{   int x=0;
    bool f=0;
    char c=getchar();
    while(!isdigit(c))f|=(c=='-'),c=getchar();
    while(isdigit(c))x=x*10+(c&15),c=getchar();
    return f?-x:x;
}
using namespace std;
struct ques
{   int opt,t,l,r,id;
}op[400005];
struct bb
{   int t,l,r;
    bool operator <(const bb &b)const{return l==b.l?r<b.r:l<b.l;}
    bool operator ==(const bb &b)const{return t==b.t&&l==b.l&&r==b.r;}
}tp,dl[10];
struct BB
{   int t;
    bb l,r;
    bool operator <(const BB &b)const{return t==b.t?(l==b.l?r<b.r:l<b.l):t<b.t;}
};
int T,n,q,now,cnt;
bool ans[200005];
set<bb> s;
set<bb>::iterator L,R;
set<BB> S;
set<BB>::iterator ls;
inline bool cmp(const ques &a,const ques &b){return a.t==b.t?a.opt<b.opt:a.t<b.t;}
inline void check(const bb &a,const bb &b){int t=(b.l+b.t-a.r+a.t)/2;S.insert({t,a,b});return ;}
inline bool eras(const bb &a,int l,int r)
{   int L=a.l-(now-a.t),R=a.r+(now-a.t);
    if(l<=L&&R<=r)
    {   s.erase(a);
        return 1;
    }
    if(L<=l&&r<=R)
    {   s.erase(a);
        dl[++cnt].t=now,dl[cnt].l=L,dl[cnt].r=l-1;
        if(dl[cnt].l>dl[cnt].r)cnt--;
        dl[++cnt].t=now,dl[cnt].l=r+1,dl[cnt].r=R;
        if(dl[cnt].l>dl[cnt].r)cnt--;
        return 1;
    }
    if(L>=l&&L<=r)
    {   s.erase(a);
        dl[++cnt].t=now,dl[cnt].l=r+1,dl[cnt].r=R;
        if(dl[cnt].l>dl[cnt].r)cnt--;
        return 1;
    }
    if(R>=l&&R<=r)
    {   s.erase(a);
        dl[++cnt].t=now,dl[cnt].l=L,dl[cnt].r=l-1;
        if(dl[cnt].l>dl[cnt].r)cnt--;
        return 1;
    }
    return 0;
}
signed main()
{   T=read();
    while(T--)
    {   n=read();
        for(int i=1,x,r;i<=n;++i)
        {   op[i].opt=0,op[i].t=read();
            x=read(),r=read();
            op[i].l=x-r+1,op[i].r=x+r-1;
        }
        q=read();
        for(int i=1;i<=q;++i)op[i+n].opt=1,op[i+n].t=read(),op[i+n].l=op[i+n].r=read(),op[i+n].id=i,ans[i]=0;
        // if(T==1102)
        // {   cout<<n<<endl;
        //     for(int i=1;i<=n;++i)cout<<op[i].t<<' '<<(op[i].l+op[i].r)/2<<' '<<op[i].r-(op[i].l+op[i].r)/2+1<<endl;
        //     cout<<q<<endl;
        //     for(int i=1;i<=q;++i)cout<<op[i+n].t<<' '<<op[i+n].l<<endl;
        // }
        sort(op+1,op+n+q+1,cmp);
        s.clear(),S.clear(),now=0;
        s.insert({0,0,0});
        for(int i=1;i<=n+q;++i)
        {   //cerr<<op[i].opt<<' '<<op[i].t<<' '<<op[i].l<<' '<<op[i].r<<endl;
            //for(auto TP:s)cerr<<TP.t<<' '<<TP.l<<' '<<TP.r<<endl;
            if(T==992)
            {   cout<<op[i].opt<<' '<<op[i].t<<' '<<op[i].l<<' '<<op[i].r<<' '<<op[i].id<<endl;
            }
            now=op[i].t;
            if(!S.empty())ls=S.begin();//,cerr<<((*ls).t)<<' '<<(*ls).l.l<<' '<<(*ls).l.r<<endl;
            while(!S.empty()&&(*ls).t<=now)
            {   //cerr<<"???"<<(*ls).t<<' '<<(*ls).l.l<<' '<<(*ls).l.r<<"       "<<(*ls).r.l<<' '<<(*ls).r.r<<endl;
                L=s.find((*ls).l),R=s.find((*ls).r);
                if(L!=s.end()&&R!=s.end())
                {   int tl=(*L).l-(now-(*L).t),tr=(*R).r+(now-(*R).t);
                    tp.t=now,tp.l=tl,tp.r=tr;
                    if(L!=s.begin())
                    {   L--;
                        check(*L,tp);
                        L++;
                    }
                    R++;
                    if(R!=s.end())check(tp,*R);
                    R--;
                    s.insert(tp);
                    s.erase(L),s.erase(R);
                }
                S.erase(ls);
                if(!S.empty())ls=S.begin();//,cerr<<((*ls).t)<<' '<<(*ls).l.l<<' '<<(*ls).l.r<<endl;
            }
            // for(auto TP:s)cerr<<TP.t<<' '<<TP.l<<' '<<TP.r<<endl;
            if(op[i].opt==0)
            {   cnt=0;
                L=s.lower_bound({0,op[i].l,op[i].l});
                if(L!=s.begin())L--;
                bool flag=0;
                for(;L!=s.end();)
                {   R=L;
                    R++;
                    if(eras(*L,op[i].l,op[i].r))flag=1;
                    else if(flag)break;
                    L=R;
                }
                //cerr<<"#!#$@   "<<cnt<<endl;
                for(int j=1;j<=cnt;++j)s.insert(dl[j]);//,cerr<<dl[j].l<<' '<<dl[j].r<<endl;
                for(int j=1;j<=cnt;++j)
                {   L=s.find(dl[j]);
                    if(L!=s.begin())
                    {   L--;
                        check(*L,dl[j]);
                        L++;
                    }
                    if(j==cnt)
                    {   L++;
                        // if(op[i].t==9&&op[i].l==-14)cerr<<"!!!"<<' '<<(*L).l<<' '<<(*L).r<<endl;
                        if(L!=s.end())check(dl[j],*L);
                    }
                }
            }
            else
            {   if(s.empty())
                {   ans[op[i].id]=0;
                    continue;
                }
                L=s.lower_bound({0,op[i].l,op[i].r});
                // cerr<<"!!!";
                if(L==s.end())
                {   L--;
                    if((*L).r+(now-(*L).t)>=op[i].r)ans[op[i].id]|=1;
                }
                else if(L!=s.begin())
                {   L--;
                    if((*L).r+(now-(*L).t)>=op[i].r)ans[op[i].id]|=1;
                    L++;
                    if((*L).l-(now-(*L).t)<=op[i].l)ans[op[i].id]|=1;
                }
                else if(!s.empty())
                {   //if(op[i].t==27)cerr<<"!!!!"<<(*L).l-(now-(*L).t)<<' '<<op[i].l<<endl;
                    if((*L).l-(now-(*L).t)<=op[i].l)ans[op[i].id]|=1;
                }
            }
        }
        if(T==0){ for(int i=1;i<=q;++i)
       {   if(ans[i])printf("@");
             else printf("*");
         }
         printf("\n");}
    }
    return 0;
}

详细

Test #1:

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

input:

1
2
3 -1 1
2 1 1
3
1 1
3 1
2 1

output:

@@*

result:

ok single line: '@@*'

Test #2:

score: -100
Wrong Answer
time: 285ms
memory: 12704kb

input:

1109
9
11 16 5
18 -3 7
45 -5 2
7 4 3
19 -2 7
16 10 4
30 1 7
11 8 3
41 -10 7
9
19 4
18 4
17 1
35 4
11 12
45 -8
19 6
7 6
7 7
8
8 -6 2
2 3 1
11 -5 2
15 -3 4
21 2 3
5 0 1
8 -3 1
14 4 4
5
21 -1
17 2
13 -1
21 9
17 4
6
6 8 2
4 6 2
10 9 1
11 8 1
15 2 1
6 5 1
8
3 2
10 8
3 3
3 4
10 9
13 5
7 6
12 9
3
34 8 4
17...

output:

1 327 627378 627378 7616
1 438 117 117 3859
1 438 116 116 1471
0 494 61 513 0
1 494 61 61 6377
0 548 -69 5 0
1 548 7 7 7976
1 548 5 5 3228
0 747 206 236 0
1 747 206 206 1857
1 919 378 378 2247
1 969 272095 272095 1409
0 1023 420 480 0
1 1207 1589365 1589365 6177
0 1383 122 166 0
0 1796 59 209 0
1 17...

result:

wrong answer 1st lines differ - expected: '*@@@**@*@', found: '1 327 627378 627378 7616'