QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#537376#9221. Missing Boundariesttbchimbu999#WA 194ms37004kbC++201.8kb2024-08-30 11:32:202024-08-30 11:32:20

Judging History

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

  • [2024-08-30 11:32:20]
  • 评测
  • 测评结果:WA
  • 用时:194ms
  • 内存:37004kb
  • [2024-08-30 11:32:20]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n, L;
pair<int, int> a[N];
vector<pair<int, int> > b;
map<int, bool> mark;
multiset<int> s;
void reinit() {
	b.clear();
	mark.clear();
	s.clear();
}
void solve() {
	cin >> n >> L;
	bool ok = 1;
	int cnt = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i].first >> a[i].second;
		if (a[i].first != -1 && a[i].second != -1 && !s.empty() && *--s.end() >= a[i].first) {
			int tmp = *s.lower_bound(a[i].first);
			if (tmp <= a[i].second) ok = 0;
		}
		if (a[i].first != -1) s.insert(a[i].first);
		if (a[i].second != -1) s.insert(a[i].second);
		if (a[i].first != -1) b.push_back({a[i].first, 0});
		if (a[i].second != -1) b.push_back({a[i].second, 1});
		if (a[i].first != -1 && a[i].second != -1) {
			mark[a[i].first] = mark[a[i].second] = 1;
			if (a[i].first < a[i].second) mark[a[i].first + 1] = mark[a[i].second - 1] = 1;
		}
		if (a[i].first == -1 && a[i].second == -1) ++cnt;
	}
	sort(b.begin(), b.end());
	int mn = 0, pre = 0;
	for (auto &i : b) {
		int pos = i.first, type = i.second;
		if (pos == pre) ok = 0;
		if (pos > 1 && type == 0 && !mark[pos - 1]) ++mn;
		// cerr << "DB>> " << pos << " : " << mn << '\n';
		mark[pos] = 1;
		pre = pos;
	}
	int mx = L - b.size();
	// cerr << "DB>> " << mn << ' ' << mx << '\n';
	if (b.back().first < L && b.back().second == 1) ++mn;
	if (ok && mn <= cnt && cnt <= mx) cout << "TAK\n";
	else cout << "NIE\n";
}
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifdef LOCAL
	    // freopen("TEST.inp", "r", stdin);
	    // freopen("TEST.out", "w", stdout);
    #else
    	// freopen("TEST.inp", "r", stdin);
    	// freopen("TEST.out", "w", stdout);
    #endif
 	int t;
 	cin >> t;
 	while (t--) {
 		solve();
 		reinit();
 	}   
    return 0;
}

詳細信息

Test #1:

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

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: 194ms
memory: 37004kb

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'