QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#548663 | #9221. Missing Boundaries | Survivor_winner | WA | 282ms | 29976kb | C++14 | 1.3kb | 2024-09-05 19:54:44 | 2024-09-05 19:54:45 |
Judging History
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.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;
for (auto i : mp)
{
now += i.second;
if (last)
{
cnt2 -= i.first - last;
last = 0;
}
if (i.first > m) break;
if (now >= 2) flag = false;
if (now == 0) cnt--, last = i.first;
}
cout << ((flag && cnt >= 0 && cnt2 <= 0) ? "TAK" : "NIE") << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3620kb
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: 282ms
memory: 29976kb
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'