QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#668880#9221. Missing BoundariesLegend_dy#WA 33ms6000kbC++202.4kb2024-10-23 16:25:412024-10-23 16:25:47

Judging History

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

  • [2024-10-23 16:25:47]
  • 评测
  • 测评结果:WA
  • 用时:33ms
  • 内存:6000kb
  • [2024-10-23 16:25:41]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

// #define int long long 
#define endl '\n'

bool solve() {
    int n, L, mn = 0, mx = 0, cnt = 0;
    cin >> n >> L;
    vector<pair<int, int>> v4, v23;
    vector<pair<int, int>> st;
    for(int i = 1; i <= n; i++) {
        int a, b;
        cin >> a >> b;
        if(a == -1 && b == -1)
            cnt++;
        else if(a == -1) {
            v23.push_back({b, 2});
            mx--;
        }
        else if(b == -1) {
            v23.push_back({a, 1});
            mx--;
        }
        else
            v4.push_back({a, b});
    }
    int lst = 0;
    sort(v4.begin(), v4.end());
    sort(v23.begin(), v23.end());
    for(auto [a, b] : v4) {
        if(lst >= a) {
            // cout << "ga?" << endl;
            return 0;
        }
        if(lst + 1 <= a - 1) {
            st.push_back({lst + 1, a - 1});
            mx += a - 1 - lst;
        }
        lst = b;
    }
    if(lst + 1 <= L) {
        st.push_back({lst + 1, L});
        mx += L - lst;
    }
    int j = 0;
    for(int i = 0; i < v23.size(); i++) {
        auto [x, tp] = v23[i];
        while(j < st.size() && st[j].second < x) {
            if(st[j].first <= st[j].second)
                mn++;
            j++;
        }
        if(j >= st.size()) {
            // cout << "why?" << endl;
            return 0;
        }
        if(tp == 2) {
            //[-1, x]
            if(st[j].first > x) {
                // cout << "QAQ" << endl;
                return 0;
            }
            st[j].first = x + 1;
        } else {
            //[x, -1]
            if(st[j].first > x) {
                // cout << "QaQ" << endl;
                return 0;
            }
            if(st[j].first < x) mn++;
            st[j].first = st[j].second + 1;
            if(i + 1 < v23.size())
                st[j].first = min(st[j].first, v23[i + 1].first);
        }
    }
    while(j < st.size()) {
        if(st[j].first <= st[j].second)
            mn++;
        j++;
    }
    // cout << "min = " << mn << "  max = " << mx << endl;
    if(cnt < mn || cnt > mx)
        return 0;
    return 1;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;
    while (t--) {
        if(solve())
            cout << "TAK" << endl;
        else
            cout << "NIE" << endl;
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 27ms
memory: 6000kb

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: 3492kb

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: 33ms
memory: 5204kb

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: 25ms
memory: 4224kb

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:

TAK
NIE

result:

wrong answer 1st lines differ - expected: 'NIE', found: 'TAK'