QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#548680#9221. Missing BoundariesSurvivor_winnerWA 172ms31292kbC++141.5kb2024-09-05 20:01:392024-09-05 20:01:40

Judging History

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

  • [2024-09-05 20:01:40]
  • 评测
  • 测评结果:WA
  • 用时:172ms
  • 内存:31292kb
  • [2024-09-05 20:01:39]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t;
	cin >> t;
	while (t--)
	{
		int n, m, k = 2e9, cnt = 0;
		cin >> n >> m;
		map<int, int> mp, mp1, mp2;
		set<int> s, s2;
		for (int i = 1; i <= n; i++)
		{
			int l, r;
			cin >> l >> r;
			if (l == -1 && r == -1) cnt++;
			else if (l != -1 && r != -1) mp[l]++, mp[r + 1]--, s.insert(l), s2.insert(r + 1);
			else if (l != -1) k = min(k, l), mp1[l]++;
			else mp2[r]++, s.insert(r + 1);
		}
		int cnt2 = cnt;
		s.insert(m + 1);
		bool flag = true;
		for (auto i : mp1)
		{
			if (i.second >= 2) flag = false;
			else
			{
				int x = *s.upper_bound(i.first);
				mp[i.first]++, mp[x]--;
			}
		}
		s2.insert(1);
		for (auto i : mp2)
		{
			if (i.second >= 2)
			{
				flag = false;
				continue;
			}
			if (i.first >= k) continue;
			int x = *(--s2.upper_bound(i.first));
			mp[x]++, mp[i.first + 1]--;
		}
		mp[1] = mp[1], mp[m + 1] = mp[m + 1];
		int now = 0, last = 0, last2 = 0;
		for (auto i : mp)
		{
			now += i.second;
			if (last)
			{
				cnt2 -= i.first - last;
				last = 0;
			}
			if (last2 && (now || i.first == m + 1))
			{
				if (!mp2[i.first - 1]) flag = false;
				last2 = 0;
			}
			if (i.first > m) break;
			if (now >= 2) last2 = i.first;
			if (now == 0) cnt--, last = i.first;
		}
		cout << ((flag && cnt >= 0 && cnt2 <= 0) ? "TAK" : "NIE") << '\n'; 
	}
	return 0;
}

詳細信息

Test #1:

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

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: 172ms
memory: 31292kb

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'