QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#529133#9221. Missing Boundariesucup-team3282#WA 92ms7168kbC++201.7kb2024-08-24 09:49:252024-08-24 09:49:29

Judging History

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

  • [2024-08-24 09:49:29]
  • 评测
  • 测评结果:WA
  • 用时:92ms
  • 内存:7168kb
  • [2024-08-24 09:49:25]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
pair<int,int>x[10000050];
bool cmp(pair<int,int>a,pair<int,int>b){
    if(a.first*b.first)return a.first<b.first;
    if(a.second*b.second)return a.first<b.first;
    if(a.first+a.second==0)return false;
    if(b.first+b.second==0)return true;
    if(a.first==0)return a.second<b.first;
    else return b.second>a.first;
}
int main(){
    int t;cin>>t;while(t--){
        bool flag=1;
        int L,n;cin>>n>>L;
        int cnt=0,rdd=0;
        for(int i=1;i<=n;i++){
            cin>>x[i].first>>x[i].second;
            if(x[i].first==-1)x[i].first=0;
            if(x[i].second==-1)x[i].second=0;
            if(x[i].first+x[i].second==0)cnt++;
            if(x[i].first*x[i].second){
                if(x[i].second<x[i].first)flag=0;
                rdd+=x[i].second-x[i].first;
            }
        }
        if(L-rdd<n){
            cout<<"NIE"<<endl;
            continue;
        }
        sort(x+1,x+n+1,cmp);
        n-=cnt;
        int lst=0,op=0;
        for(int i=1;i<=n;i++){
            if(!x[i].first){
                if(x[i].second<=lst)flag=0;
            }
            else{
                if(x[i].first<=lst)flag=0;
                if(x[i].first>lst+1){
                    if(!op)cnt--;
                }
            }
            if(x[i].second){
                op=0;
                lst=x[i].second;
            }else{
                op=1;
                lst=x[i].first;
            }
        }
        if(lst!=L&&op!=1)cnt--;
        if(cnt<0)flag=false;
        if(flag)cout<<"TAK\n";
        else cout<<"NIE\n";
    }

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 92ms
memory: 7168kb

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'