QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#719875#9221. Missing Boundariesicpc_zhzx034WA 0ms22108kbC++142.8kb2024-11-07 09:32:582024-11-07 09:32:59

Judging History

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

  • [2024-11-07 09:32:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:22108kb
  • [2024-11-07 09:32:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> Pr;
#define fi first
#define se second
#define mkp make_pair
#define pb emplace_back
// #define mid ((l+r)>>1)
#define popcnt __builtin_popcountll
const ll mod = 998244353;
inline ll read(){
	ll x=0, f=1; char ch=getchar();
	while(ch<'0' || ch>'9') { if(ch=='-') f=-1; ch=getchar(); }
	while(ch>='0' && ch<='9') x=x*10+ch-'0', ch=getchar();
	return x*f;
}
inline ll lg2(ll x){ return 63^__builtin_clzll(x); }
inline ll qpow(ll a,ll b){
	ll ans=1, base=a;
	while(b){
		if(b&1) ans=ans*base%mod;
		base=base*base%mod; b>>=1;
	}
	return ans;
}
void init(){ }
ll n,L,a[800005],b[800005],tmp[800005],cnt;
ll d[800005], tg[800005], tg2[800005], tg3[800005], vis[800005];

ll A[800005], B[800005];
ll find(ll x){
	return lower_bound(tmp+1, tmp+cnt+1, x) - tmp;
}
ll T;

vector<bool>ans;
void procedure(ll t){
	cnt=0;
	n=read(), L=read();
	for(ll i=0;i<=4*n+3;i++) tg[i]=tg2[i]=tg3[i]=vis[i]=d[i]=0;
	for(ll i=1;i<=n;i++) {
		a[i]=A[i]=read(), b[i]=B[i]=read();
		if(~a[i]){
			tmp[++cnt]=a[i];
			tmp[++cnt]=a[i]+1;
		}
		if(~b[i]){
			tmp[++cnt]=b[i];
			tmp[++cnt]=b[i]+1;
		}
	}
	tmp[++cnt] = 1;
	tmp[++cnt] = L+1;
	sort(tmp+1, tmp+cnt+1);
	cnt=unique(tmp+1, tmp+cnt+1)-(tmp+1);

	ll res = 0;
	ll hgh = L, low = 0;
	for(ll i=1;i<=n;i++){
		if((~a[i]) && (~b[i])) hgh -= (b[i]-a[i]+1);
		else if((~a[i]) || (~b[i])) hgh --;
		if(~a[i])
			a[i]=find(a[i]), tg[a[i]]=tg2[a[i]]=tg3[a[i]]=1;
		if(~b[i])
			b[i]=find(b[i]+1), tg[b[i]-1]=tg2[b[i]-1]=tg3[b[i]-1]=2;
		if((~a[i]) && (~b[i])){
			d[a[i]] ++;
			d[b[i]] --;
			// cout<<"add "<<a[i]<<" -> "<<b[i]-1<<endl;
		}else if(~a[i]){
			d[a[i]] ++;
			d[a[i]+1] --;
			// cout<<"add on "<<a[i]<<endl;
		}else if(~b[i]){
			d[b[i]-1] ++;
			d[b[i]] --;
			// cout<<"add on "<<b[i]<<endl;
		}else{
			res ++;
		}
	}
	// cout<<"res = "<<res<<" hgh = "<<hgh<<endl;
	for(ll i=1;i<cnt;i++){
		d[i] += d[i-1];
		if(d[i] > 1){
			puts("NIE");
			return;
		}
	}
	for(ll i=1;i<cnt;i++){
		if(!tg[i]) tg[i] = tg[i-1];
	}
	for(ll i=cnt-1;i>=1;i--){
		if(!tg2[i]) tg2[i] = tg2[i+1];
	}

	for(ll i=1;i<cnt;i++){
		vis[i] = (tg[i-1] != 1 && tg2[i+1] != 2 && !tg3[i]);
		if(vis[i] && !vis[i-1]) low ++;
	}
	if(T == 30000 && t == 52){
		cout<<n<<" "<<L<<endl;
		for(ll i=1;i<=n;i++){
			cout<<A[i]<<" "<<B[i]<<endl;
		}
		cout<<low<<" "<<res<<" "<<hgh<<endl;
	}
	ans.pb((low <= res && res <= hgh));
}
int main(){
	#ifdef LOCAL
		assert(freopen("input.txt","r",stdin));
		assert(freopen("output.txt","w",stdout));
	#endif
	T=read();
	init();
	for(ll i=1;i<=T;i++) procedure(i);

	for(auto x: ans){
		if(x) puts("TAK");
		else puts("NIE");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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'