QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#560697 | #9221. Missing Boundaries | Afterlife# | WA | 34ms | 5324kb | C++17 | 1.5kb | 2024-09-12 17:26:01 | 2024-09-12 17:26:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n , L;
typedef pair<int,int> pii;
void solv() {
cin >> n >> L;
vector<pii> v;
int cnt = 0;
for(int i = 1;i <= n;i++) {
int a,b;cin >> a >> b;
if(a == -1 && b == -1) cnt++ ;
else v.push_back({a , b});
}
sort(v.begin() , v.end() , [&](pii a,pii b) {
return max(a.first , a.second) < max(b.first , b.second) ;
});
int lst = 0;
int mn = 0 , mx = 0;
v.push_back({L + 1 , L + 1}) ;
for(int i = 0;i < v.size();i++) {
if(i == 0 || v[i - 1].second != -1) {
if(v[i].first == -1) {
if(v[i].second <= lst) {cout << "NIE\n" ; return ;}
mx += v[i].second - lst - 1 ;
}
else {
if(v[i].first <= lst) {cout << "NIE\n" ; return ;}
mn += v[i].first - lst - 1;
mx += v[i].first - lst - 1;
}
}
else {
if(v[i].first == -1) {
if(v[i].second <= lst + 1) {cout << "NIE\n" ; return ;}
mx += v[i].second - lst - 2;
}
else {
if(v[i].first <= lst) {cout << "NIE\n" ; return ;}
mx += v[i].first - lst - 1;
}
}
lst = max(v[i].first , v[i].second) ;
}
if(mn <= cnt && cnt <= mx) {
cout << "TAK\n" ; return ;
}
cout << "NIE\n" ;
}
int main() {
ios::sync_with_stdio(false) ; cin.tie(0) ;
int t;cin >> t;
while(t--) solv() ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3544kb
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: 34ms
memory: 5324kb
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: 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 #4:
score: -100
Wrong Answer
time: 24ms
memory: 5180kb
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:
NIE
result:
wrong answer 1st lines differ - expected: 'TAK', found: 'NIE'