QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#538903#9221. Missing BoundariesChinese_zjc_#WA 119ms16808kbC++201.7kb2024-08-31 13:32:222024-08-31 13:32:22

Judging History

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

  • [2024-08-31 13:32:22]
  • 评测
  • 测评结果:WA
  • 用时:119ms
  • 内存:16808kb
  • [2024-08-31 13:32:22]
  • 提交

answer

#include<bits/stdc++.h>
int T,n,m,l[200005],r[200005],g,len;
signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin>>T;
    while(T--)
    {
        std::set<std::pair<int,int>> set;
        bool ans=true;
        g=0;
        len=0;
        std::cin>>n>>m;
        for(int i=1;i<=n;++i)
        {
            std::cin>>l[i]>>r[i];
            if(l[i]==-1&&r[i]==-1)
            {
                ++g;
                len+=1;
            }
            else if(r[i]==-1)
            {
                set.insert({l[i],0});
                len+=1;
            }
            else if(l[i]==-1)
            {
                set.insert({r[i],1});
                len+=1;
            }
            else
            {
                set.insert({l[i],0});
                set.insert({r[i],1});
                len+=r[i]-l[i]+1;
            }
        }
        set.insert({m+1,0});
        for(int i=1;i<=n;++i)
        {
            if(~l[i]&&~r[i])
            {
                std::set<std::pair<int,int>>::iterator iter=set.upper_bound({l[i],10});
                if(iter->first<r[i])
                    ans=false;
            }
        }
        int cur=0,p=1;
        for(auto i:set)
        {
            if(cur==i.first)
                ans=false;
            if(i.second)
            {
                p=1;
                cur=i.first;
            }
            else
            {
                if(p==1&&cur!=i.first-1)
                    --g;
                p=0;
                cur=i.first;
            }
        }
        ans&=g>=0&&len<=m;
        std::cout<<(ans?"TAK":"NIE")<<std::endl;
    }
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3616kb

input:

3
4 51
1 -1
11 50
-1 -1
-1 10
3 2
-1 -1
-1 -1
-1 -1
2 3
1 2
2 3

output:

TAK
NIE
NIE

result:

ok 3 lines

Test #2:

score: -100
Wrong Answer
time: 119ms
memory: 16808kb

input:

1
200000 1000000000
490669427 -1
224278942 224287156
821104480 -1
861696576 861702036
807438935 807440055
574078002 574083717
465630141 -1
195378188 -1
-1 13500961
-1 977536179
92893115 -1
-1 661145418
-1 215804863
-1 685338515
544348999 -1
465532902 -1
130346949 -1
-1 526666304
635604584 635605404
...

output:

NIE

result:

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