QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#536920#9221. Missing BoundariesFavorGew#WA 34ms5192kbC++201.6kb2024-08-29 18:03:152024-08-29 18:03:17

Judging History

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

  • [2024-08-29 18:03:17]
  • 评测
  • 测评结果:WA
  • 用时:34ms
  • 内存:5192kb
  • [2024-08-29 18:03:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
void Do() {
    int n, MX, cnt = 0;
    cin >> n >> MX;
    vector<pair<int, int>> A;
    for(int i = 1; i <= n; ++ i) {
        int a, b;
        cin >> a >> b;
        if(a == -1 && b == -1) {
            ++ cnt;
            continue;
        }
        A.push_back({a, b});
    }
    A.push_back({0, 0});
    A.push_back({MX + 1, MX + 1});
    sort(A.begin(), A.end(), [](auto x, auto y) {
        auto [a, b] = x;
        auto [c, d] = y;
        return max(a, b) < max(c, d);
    });
    int L = 0, R = 0;
    for(int i = 0; i + 1 < A.size(); ++ i) {
        auto [a, b] = A[i];
        auto [c, d] = A[i + 1];
        if(a >= c && a != -1 && c != -1) {
            cout << "NIE\n";
            return;
        }
        if(b >= d && b != -1 && d != -1) {
            cout << "NIE\n";
            return;
        }
        if(a >= c && a != -1 && c != -1) {
            cout << "NIE\n";
            return;
        }
        if(b >= d && b != -1 && d != -1) {
            cout << "NIE\n";
            return;
        }
        if(c == -1) c = 1e9;
        if(d == -1) d = 1e9;
        int mx = max(a, b), mn = min(c, d);
        if(mx + 1 < mn && b != -1 && c != -1) {
            ++ L;
        }
        {
            R += mn - mx - 1;
        }
    }
    // cerr << L << " " << R << endl;
    if(L <= cnt && cnt <= R) {
        cout << "TAK\n";
    }
    else {
        cout << "NIE\n";
    }
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T; cin >> T;
    while(T --) {
        Do();
    } 
}

详细

Test #1:

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

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: 34ms
memory: 5192kb

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'