QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#529792#9221. Missing Boundariesucup-team1004#WA 1ms5740kbC++141.1kb2024-08-24 14:02:152024-08-24 14:02:15

Judging History

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

  • [2024-08-24 14:02:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5740kb
  • [2024-08-24 14:02:15]
  • 提交

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'