QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#695230#9221. Missing BoundariesjimmyywangWA 24ms8228kbC++141.9kb2024-10-31 19:33:542024-10-31 19:33:56

Judging History

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

  • [2024-10-31 19:33:56]
  • 评测
  • 测评结果:WA
  • 用时:24ms
  • 内存:8228kb
  • [2024-10-31 19:33:54]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
// #define mp make_pair
#define pb push_back
#define f(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
ll rd(){
    ll x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
#define d rd()
ll n,m;
struct node{ll l,r;}a[1000010];
bool cmp(node a,node b){
    if(a.l!=-1&&b.l!=-1)return a.l<b.l;
    if(a.l==-1)return a.r<b.l;
    if(b.l==-1)return a.l<b.r;
}
int main(){
    ll T=d;while(T--){
        n=d,m=d;ll num=0;ll c=0;
        f(i,1,n){
            ll x=d,y=d;
            if(x+y==-2)num++;
            else a[++c]={x,y};
        }a[++c]={0,0},a[++c]={m+1,m+1};
        sort(a+1,a+c+1,cmp);ll ok=0;bool fl=1;
        ll l,r,L,R;
        f(i,2,c){
            l=a[i-1].l,r=a[i-1].r,L=a[i].l,R=a[i].r;
            // cout<<l<<" "<<r<<" "<<L<<" "<<R<<endl;
            if(r!=-1&&L!=-1){
                if(r>=L){fl=0;break;}
                if(L>r+1){
                    if(!num){fl=0;
                    if(n>100){
                        cout<<a[i-2].l<<" "<<a[i-2].r<<" "<<l<<" "<<r<<" "<<L<<" "<<R<<endl;
                    }
                    break;}
                    num--;ok+=L-r-1-1;
                }continue;
            }if(r!=-1&&R!=-1){
                if(r==R){fl=0;break;}
                ok+=R-r-1;continue;
            }if(l!=-1&&L!=-1){
                if(l==L){fl=0;break;}
                ok+=L-l-1;continue;
            }if(l!=-1&&R!=-1){
                if(l==R){fl=0;break;}
                ok+=R-l-1;continue;
            }
        }
        // cout<<ok<<" "<<num<<endl;
        if(ok<num)fl=0;
        if(!fl){
            puts("NIE");
            if(n>100)cout<<l<<" "<<r<<" "<<L<<" "<<R<<" "<<num<<endl;
        }
        else puts("TAK");
    }
    return 0;
}
/*
5 10
-1 -1
-1 -1
3 3
-1 4
5 10
*/

详细

Test #1:

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

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: 24ms
memory: 8228kb

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:

207094 -1 212950 217864 228626 -1
NIE
212950 217864 228626 -1 0

result:

wrong answer 1st lines differ - expected: 'TAK', found: '207094 -1 212950 217864 228626 -1'