QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#695256#9221. Missing BoundariesjimmyywangWA 25ms7736kbC++141.9kb2024-10-31 19:38:202024-10-31 19:38:21

Judging History

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

  • [2024-10-31 19:38:21]
  • 评测
  • 测评结果:WA
  • 用时:25ms
  • 内存:7736kb
  • [2024-10-31 19:38:20]
  • 提交

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){
    return max(a.l,a.r)<max(b.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
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 25ms
memory: 7136kb

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:

TAK

result:

ok single line: 'TAK'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3700kb

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 #4:

score: 0
Accepted
time: 25ms
memory: 7736kb

input:

1
197838 400000
34167 34169
352180 -1
235963 -1
-1 -1
160401 160405
347288 -1
270353 270354
214502 214504
183243 183245
-1 -1
-1 36193
-1 -1
-1 17557
273498 273500
269137 -1
395099 395100
285515 285518
-1 -1
71041 71042
324060 -1
-1 385151
-1 379645
-1 -1
-1 185142
-1 191584
89259 89261
328347 32834...

output:

TAK

result:

ok single line: 'TAK'

Test #5:

score: -100
Wrong Answer
time: 21ms
memory: 6504kb

input:

2
97340 150000
-1 101927
105937 -1
-1 107253
-1 47307
110550 -1
84061 84062
125176 125177
-1 15915
29617 -1
-1 -1
-1 43147
115958 -1
101807 101808
24866 -1
66826 66828
-1 31640
-1 5610
1281 1284
-1 -1
-1 -1
-1 73973
-1 2945
29064 -1
30653 -1
-1 63714
-1 -1
141389 141390
-1 27465
57358 -1
47388 47389...

output:

NIE
-1 63114 63114 -1 21931
NIE
123286 -1 123286 123289 17173

result:

wrong answer 2nd lines differ - expected: 'NIE', found: '-1 63114 63114 -1 21931'