QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#549496#9221. Missing Boundariesknightofshadow#RE 0ms3628kbC++141.1kb2024-09-06 16:27:072024-09-06 16:27:08

Judging History

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

  • [2024-09-06 16:27:08]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3628kb
  • [2024-09-06 16:27:07]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll num[202020];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll t,n,rn,l,r,cnt,lim,count;
	cin>>t;
	while(t--){
		cin>>n>>rn;
		cnt=lim=count=0;
		vector<ll>a1,a2;
		for(int i=1;i<=n;i++){
			num[i]=0;
		} 
		ll f=0;
		for(int i=1;i<=n;i++){
			cin>>l>>r;
			if(l!=-1&&r!=-1){
				for(int j=l;j<=r;j++){
					if(num[j]==1) f=1;
					num[j]=1;
				}	
			}
			else{
				if(l!=-1){
					if(num[l]==1) f=1;
					num[l]=1;
					a1.push_back(l);
				}
				else if(r!=-1){
					if(num[r]==1) f=1;
					num[r]=1;
					a2.push_back(r);
				}
				else cnt++;
			}
		}
		if(f){
			cout<<"NIE"<<'\n';
			continue;
		}
		for(auto it:a1){
			ll y=it;
			while(num[y+1]==0&&y<rn) y++;
			for(int i=it;i<=y;i++) num[i]=1;
			lim+=y-it;
		}
		for(auto it:a2){
			ll y=it;
			while(num[y-1]==0&&y>1) y--;
			for(int i=y;i<=it;i++) num[i]=1;
			lim+=it-y;
		}
		for(int i=1;i<=n;i++){
			if(num[i]==0&&(num[i-1]==1||i==1)) count++;
		}
		if(count<=cnt&&count<=lim) cout<<"TAK"<<'\n';
		else cout<<"NIE"<<'\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Runtime Error

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:


result: