QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#697651#9221. Missing Boundariesucup-team3160#WA 46ms7812kbC++141.2kb2024-11-01 15:14:312024-11-01 15:14:38

Judging History

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

  • [2024-11-01 15:14:38]
  • 评测
  • 测评结果:WA
  • 用时:46ms
  • 内存:7812kb
  • [2024-11-01 15:14:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

const int N = 200005;
int T, n, m, m2, L;
int l[N], r[N], lv[N], rv[N], perm[N];
bool cmp(int x, int y)
{
	return l[x] < l[y];
}

int main()
{
	scanf("%d", &T);
	while (T--)
	{
		scanf("%d%d", &n, &L);
		m = m2 = 0;
		for (int i = 1; i <= n; i++)
		{
			perm[i] = i;
			scanf("%d%d", &lv[i], &rv[i]);
			if (lv[i] == -1 && rv[i] == -1)
				m2++;
			else if (lv[i] == -1)
			{
				m++;
				l[m] = r[m] = rv[i];
				lv[m] = 1;
				rv[m] = 0;
			}
			else if (rv[i] == -1)
			{
				m++;
				l[m] = r[m] = lv[i];
				lv[m] = 0;
				rv[m] = 1;
			}
			else
			{
				m++;
				l[m] = lv[i];
				r[m] = rv[i];
				lv[m] = rv[m] = 0;
			}
		}
		sort(perm + 1, perm + 1 + m, cmp);
		int mn = 0, mx = 0;
		bool ok = true;
		for (int i = 2; i <= m; i++)
		{
			int t = perm[i], t2 = perm[i - 1];
			if (l[t] <= r[t2]) ok = false;
			mx += l[t] - r[t2] - 1;
			if (!rv[t2] && !lv[t] && l[t] > r[t2] + 1)
				mn++;
		}
		mx += l[1] - 1;
		if (!lv[1] && l[1] > 1) mn++;
		mx += L - r[m];
		if (!rv[m] && r[m] < L) mn++;
		if (ok && m2 >= mn && m2 <= mx) printf("TAK\n");
		else printf("NIE\n");
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5972kb

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: 46ms
memory: 7812kb

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'