QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#549265 | #9221. Missing Boundaries | plutos | WA | 0ms | 3724kb | C++17 | 1.7kb | 2024-09-06 13:39:03 | 2024-09-06 13:39:03 |
Judging History
answer
#include <bits/stdc++.h>
void Yes() { std::cout << "YES" << "\n"; return; }
void No() { std::cout << "NO" << "\n"; return; }
template <typename T>
void out(T x) { std::cout << x << "\n"; }
using namespace std;
using ll=long long;
using PII=pair<ll,ll>;
const ll N = 2e5 + 10;
struct node{
ll l,r;
}no[N];
void Solve()
{
ll n,L;
cin >> n >> L;
ll Dis = L;
ll num = 0;
for(ll i = 1;i <= n;i ++ )
{
ll l,r;
cin >> l >> r ;
if(l == -1 && r == -1) {
l = r = 2e9;
num++;
}
else if(l != -1 && r != -1) {
Dis -= (r-l+1);
}
else if(l == -1) l = 2e9,Dis --;
else if(r == -1) r = 2e9,Dis--;
no[i] = {l,r};
}
no[n+1] = {L+1,L+1};
sort(no+1,no+1+n,[&](node a,node b) {
return min(a.l,a.r) < min(b.l,b.r);
});
ll now = 1;
for(ll i = 1;i<=n;i++)
{
if(no[i].l == 2e9 && no[i].r == 2e9) {
break;
}
if(now == 2e9) {
now = no[i].r + 1;
now = min(now,(ll)2e9);
continue;
}
if(no[i].l < now ) {
out("NIE");
return;
}
if(no[i].l == now) {
now = no[i].r;
}
else {
num--;
}
}
if(now < L + 1) num--;
if(Dis < num || num < 0 || now != L + 1) {
out("NIE");
return;
}
else {
out("TAK");
return;
}
}
signed main()
{
std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll t=1;
cin>>t;
while(t--)
Solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3724kb
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:
NIE NIE NIE
result:
wrong answer 1st lines differ - expected: 'TAK', found: 'NIE'