QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#529792 | #9221. Missing Boundaries | ucup-team1004# | WA | 1ms | 5740kb | C++14 | 1.1kb | 2024-08-24 14:02:15 | 2024-08-24 14:02:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
map<int,int> t;
int T,n,m,a[N],b[N];
int calc()
{
int sum=0,ans=0;
for(auto k:t)
{
sum+=k.second;
if(sum>2) return 1e9;
ans+=(sum==0);
}
return ans;
}
int main()
{
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&m);
long long len=0;
int cnt=0;
vector<int> v{0,m+1};
for(int i=1;i<=n;i++)
{
scanf("%d%d",&a[i],&b[i]);
if(a[i]!=-1&&b[i]!=-1) len+=b[i]-a[i]+1;
else len++;
if(a[i]==-1&&b[i]==-1) cnt++;
if(a[i]!=-1) v.push_back(a[i]);
if(b[i]!=-1&&a[i]!=b[i]) v.push_back(b[i]);
}
sort(v.begin(),v.end());
if(len>m||unique(v.begin(),v.end())!=v.end())
{
puts("NIE");
continue;
}
t.clear();
t[m+1]=2,t[1]=0;
for(int i=1;i<=n;i++)
{
if(a[i]==-1&&b[i]==-1) continue;
int val=1;
if(a[i]==-1) b[i]=*++lower_bound(v.begin(),v.end(),a[i])-1;
else if(b[i]==-1) a[i]=*--lower_bound(v.begin(),v.end(),b[i])+1;
else val=2;
t[a[i]]+=val,t[b[i]+1]-=val;
}
puts(calc()<=cnt?"TAK":"NIE");
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5740kb
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:
NIE NIE NIE
result:
wrong answer 1st lines differ - expected: 'TAK', found: 'NIE'