QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#529313#9221. Missing Boundariesucup-team3699#WA 35ms7032kbC++202.9kb2024-08-24 11:47:422024-08-24 11:47:42

Judging History

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

  • [2024-08-24 11:47:42]
  • 评测
  • 测评结果:WA
  • 用时:35ms
  • 内存:7032kb
  • [2024-08-24 11:47:42]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define pb push_back
#define F first 
#define S second 

const int mol=998244353;

void solve(){
    int n, l;
    cin>>n>>l;
    int c=0;
    vector<pair<int, int>>t1, t2, t3;
    for(int i=1;i<=n;i++){
        int g, h;
        cin>>g>>h;
        if(g==-1&&h==-1) c++;
        else if(g==-1) t1.pb({g, h});
        else if(h==-1) t2.pb({g, h});
        else t3.pb({g, h});
    }
    sort(t1.begin(), t1.end());
    sort(t2.begin(), t2.end());
    sort(t3.begin(), t3.end());
    int mx=0, ca=0, id1=0, id2=0, id3=0, ne=0, un=0;
    while(mx<l){
        if(id1<t1.size()&&t1[id1].S<=mx) {
            cout<<"NIE\n";
            return;

        }
        if(id2<t2.size()&&t2[id1].F<=mx) {
            cout<<"NIE\n";
            return;

        }
        if(id3<t3.size()&&t3[id3].F<=mx) {
            cout<<"NIE\n";
            return;

        }
        if(id2<t2.size()&&id3<t3.size()){
            if(id1<t1.size()&&t1[id1].S<min(t2[id2].F, t3[id3].F)){
                ca+=t1[id1].S-mx-1, mx=t1[id1].S, id1++, un=0;
            }
            else {

                if(min(t2[id2].F, t3[id3].F)>mx+1) {
                    if(un==0) ne++;
                    ca+=min(t2[id2].F, t3[id3].F)-mx-1;    
                }
                if(t2[id2].F<t3[id3].F){
                    mx=t2[id2].F, id2++, un=1;
                }
                else{
                    mx=t3[id3].S, id3++;
                    un=0;
                }
            }
        }
        else if(id2<t2.size()){
            if(id1<t1.size()&&t1[id1].S<t2[id2].F){
                ca+=t1[id1].S-mx-1, mx=t1[id1].S, id1++, un=0;
            }
            else {
                if(t2[id2].F>mx+1) {
                    if(un==0)ne++;
                    ca+=t2[id2].F-mx-1;    
                }
                mx=t2[id2].F, id2++, un=1;
            }

        }
        else if(id3<t3.size()){
            if(id1<t1.size()&&t1[id1].S<t3[id3].F){
                ca+=t1[id1].S-mx-1, mx=t1[id1].S, id1++, un=0;
            }
            else {
                if(t3[id3].F>mx+1) {
                    if(un==0)ne++;
                    ca+=t3[id3].F-mx-1;    
                }
                    mx=t3[id3].S, id3++;
                    un=0;
            }
        }
        else{
            if(id1<t1.size()){
                ca+=t1[id1].S-mx-1, mx=t1[id1].S, id1++;
            }
            else {
                ca+=l-mx;
                ne++;
                break;
            }
        }
    }
    if(ne>c){
        cout<<"NIE\n";
        return;
    }
    if(c>ca){
        cout<<"NIE\n";
        return;
    }
    cout<<"TAK\n";
}


signed main(){
    ios::sync_with_stdio(0);cin.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: 3508kb

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: 35ms
memory: 7032kb

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'