QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#548726#9221. Missing BoundariesIan_ShiWA 0ms3580kbC++141.5kb2024-09-05 20:26:312024-09-05 20:26:31

Judging History

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

  • [2024-09-05 20:26:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3580kb
  • [2024-09-05 20:26:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
struct interval{
	int x;
	int ty;
	int assigned;
}t[maxn];
bool cmp(interval p,interval q){
	return p.x<q.x;
}
int tot;
int fcnt;
int main(){
	int T;
	cin>>T;
	while(T--){
		int n,L;
		cin>>n>>L;
		int x,y;
		fcnt=0;tot=0;
		for(int i=1;i<=n;i++){
			cin>>x>>y;
			if(x==-1){
				if(y==-1){
					fcnt++;
				}else{
					t[++tot].x=y;
					t[tot].ty=2;
					t[tot].assigned=0;	
				}
			}else{
				if(y==-1){
					t[++tot].x=x;
					t[tot].ty=1;
					t[tot].assigned=0;
				}else{
					t[++tot].x=x;
					t[tot].ty=1;
					t[tot].assigned=y;
					t[++tot].x=y;
					t[tot].ty=2;
					t[tot].assigned=x;
				}
			} 
		}
		sort(t+1,t+tot+1,cmp);
		int f=0;
		for(int i=1;i<tot;i++){
			if(t[i].assigned&&t[i].ty==1){
				if(t[i].assigned!=t[i+1].x){
					f=1;
					cout<<"NIE";
					break;
				}
			}else if(t[i].x==t[i+1].x){
				f=1;
				cout<<"NIE";
				break;			
			}
		} 
		if(f==1)continue;
		int ncnt=0,ncnt1;
		if(t[1].ty==1&&t[1].x!=1){
			ncnt++;ncnt1+=t[1].x;
		}
		int nl=0;
		for(int i=1;i<tot;i++){
			if(t[i].ty==2){
				continue;
			}else{
				if(nl!=0){
					if(t[i-1].ty==2&&t[i-1].x!=(t[i].x-1)){ncnt++;ncnt1+=t[i].x-t[i-1].x+1;}
				}
				nl=t[i].x;	
			}
		}
		if(t[tot].ty==2&&t[tot].x!=L){ncnt++;ncnt1+=L-t[tot].x+1;}
		if(ncnt1>fcnt)cout<<"NIE\n";
		else if(ncnt<=fcnt)cout<<"TAK\n";
		else cout<<"NIE\n";
	}
	
	
	
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3580kb

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
TAK
NIE

result:

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