QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#549265#9221. Missing BoundariesplutosWA 0ms3724kbC++171.7kb2024-09-06 13:39:032024-09-06 13:39:03

Judging History

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

  • [2024-09-06 13:39:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3724kb
  • [2024-09-06 13:39:03]
  • 提交

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();
}

詳細信息

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'