QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#577575#9221. Missing BoundariesqwqpmpWA 68ms10404kbC++141.7kb2024-09-20 12:58:072024-09-20 12:58:07

Judging History

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

  • [2024-09-20 12:58:07]
  • 评测
  • 测评结果:WA
  • 用时:68ms
  • 内存:10404kb
  • [2024-09-20 12:58:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n'
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand()%x; }
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// head

const int MAXN=2e5+10;
ll n,l;

void solve() {
	scanf("%lld%lld",&n,&l);
	vector<pii> evt,ievt;
	ll cnt=0,nw=0;
	rep(i,1,n+1) {
		ll a,b;
		scanf("%lld%lld",&a,&b);
		if (a==-1 and b==-1) {
			cnt++;
			continue;
		}
		else if (a==-1) evt.eb(b,1),evt.eb(b+1,-1),ievt.eb(b,0);
		else if (b==-1) evt.eb(a,1),evt.eb(a+1,-1),ievt.eb(a,1);
		else evt.eb(a,1),evt.eb(b+1,-1),ievt.eb(a,1),ievt.eb(b,0);
	}
	ievt.eb(l+1,1);
	sort(all(evt));
	sort(all(ievt));
	bool ok=1;
	for (auto [a,b] : evt) {
		if (nw>=2) ok=0;
		nw+=b;
	}
	ll lasp=0,las=0,gao=0,gaol=0;
	for (auto [a,b] : ievt) {
		// cerr<<a<<" "<<b<<endl;
		if (las==0 and b==1) {
			gaol+=(a-lasp-1);
			// cerr<<a<<" "<<lasp<<endl;
			if (a-lasp-1>0) gao++;
		}
		las=b,lasp=a;
	}
	// cerr<<"gaol "<<gaol<<endl<<"cnt "<<cnt<<endl<<"gao "<<gao<<endl;
	if (gao>cnt || cnt>gaol) ok=0;
	puts((ok?"TAK":"NIE"));
}

int _;
signed main() {
	// freopen("qwq.in","r",stdin);
	// freopen("qwq.out","w",stdout);

	scanf("%d",&_);
	while (_--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
Wrong Answer
time: 68ms
memory: 10404kb

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:

NIE

result:

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