QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#538966 | #9221. Missing Boundaries | Chinese_zjc_# | WA | 116ms | 16824kb | C++20 | 1.7kb | 2024-08-31 13:41:02 | 2024-08-31 13:41:02 |
Judging History
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::multiset<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::multiset<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: 0ms
memory: 3600kb
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: 116ms
memory: 16824kb
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'