QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#537379 | #9221. Missing Boundaries | ttbchimbu999# | WA | 156ms | 37140kb | C++20 | 1.9kb | 2024-08-30 11:35:31 | 2024-08-30 11:35:31 |
Judging History
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;
}
sort(a + 1, a + 1 + n);
for (int i = 1; i <= n; ++i) {
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);
b.push_back({a[i].first, 0});
mark[a[i].first] = 1;
}
if (a[i].second != -1) {
s.insert(a[i].second);
b.push_back({a[i].second, 1});
mark[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';
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: 3652kb
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: 156ms
memory: 37140kb
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'