QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#536914 | #9221. Missing Boundaries | FavorGew# | WA | 33ms | 5192kb | C++20 | 1.6kb | 2024-08-29 18:00:50 | 2024-08-29 18:00:50 |
Judging History
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;
}
else {
R += mn - mx - 1;
}
}
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3780kb
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: 33ms
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'