QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#579492#9221. Missing BoundariesBerryPie#WA 32ms5992kbC++201.5kb2024-09-21 14:15:102024-09-21 14:15:11

Judging History

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

  • [2024-09-21 14:15:11]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:5992kb
  • [2024-09-21 14:15:10]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int N=2e5+5;
struct node{
    int l,r;
    bool L,R;
    bool operator < (const node &_) const { return l<_.l; }
}A[N];
int tot;
int cnt;
bool flag;
int n,m;

void solve(){
    cnt=tot=0;
    flag=true;
    cin>>n>>m;
    if(n>m) flag=false;
    for(int i=1; i<=n; i++){
        int l,r;
        cin>>l>>r;
        if(l==-1 && r==-1){
            cnt++;
        }else if(l==-1){
            A[++tot]=(node)<%r,r,1,0%>;
        }else if(r==-1){
            A[++tot]=(node)<%l,l,0,1%>;
        }else A[++tot]=(node)<%l,r,0,0%>;
    }
    sort(A+1,A+tot+1);
    // for(int i=1; i<=tot; i++) cout<<A[i].l<<" ~ "<<A[i].r<<" : "<<A[i].L<<" , "<<A[i].R<<"\n";
    if(!flag){
        cout<<"NIE\n";
        return;
    }
    int ans1=0,ans2=0;
    if(A[1].l!=1){
        if(!A[1].L) ans1++;
        ans2+=A[1].l-1;
    }
    for(int i=1; i<tot; i++){
        if(A[i+1].l<=A[i].r){
            flag=false;
            break;
        }else if(A[i].r<A[i+1].l-1){
            if(!A[i].R && !A[i+1].L) ans1++;
            ans2+=A[i+1].l-A[i].r;
        }
    }
    if(A[tot].r!=1){
        if(!A[tot].R) ans1++;
        ans2+=m-A[tot].r;
    }
    if(!flag){
        cout<<"NIE\n";
        return;
    }
    cout<<(cnt>=ans1 && cnt<=ans2 ? "TAK\n" : "NIE\n");
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int T;
    cin>>T;
    while(T--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 32ms
memory: 5992kb

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'