QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#529111 | #9221. Missing Boundaries | ucup-team3282# | WA | 96ms | 6500kb | C++20 | 1.7kb | 2024-08-24 09:31:43 | 2024-08-24 09:31:44 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
pair<int,int>x[10000050];
bool cmp(pair<int,int>a,pair<int,int>b){
if(a.first*b.first)return a.first<b.first;
if(a.second*b.second)return a.first<b.first;
if(a.first+a.second==0)return false;
if(b.first+b.second==0)return true;
if(a.first==0)return a.second<b.first;
else return b.second>a.first;
}
int main(){
int t;cin>>t;while(t--){
bool flag=1;
int L,n;cin>>n>>L;
int cnt=0,rdd=0;
for(int i=1;i<=n;i++){
cin>>x[i].first>>x[i].second;
if(x[i].first==-1)x[i].first=0;
if(x[i].second==-1)x[i].second=0;
if(x[i].first+x[i].second==0)cnt++;
if(x[i].first*x[i].second){
if(x[i].second<x[i].first)flag=0;
rdd+=x[i].second-x[i].first;
}
}
if(L-rdd<n){
cout<<"NIE"<<endl;
continue;
}
sort(x+1,x+n+1,cmp);
n-=cnt;
int lst=0,op=0;
for(int i=1;i<=n;i++){
// cout<<lst<<"~"<<op<<"->"<<x[i].first<<","<<x[i].second<<endl;
if(!x[i].first)x[i].first=x[i].second,op=1;
if(x[i].first<=lst)flag=0;
if(x[i].first>lst+1){
if(!op)cnt--;
}
if(x[i].second){
op=0;
lst=x[i].second;
}else{
op=1;
lst=x[i].first;
}
}
if(lst!=L&&op!=1)cnt--;
if(cnt<0)flag=false;
if(flag)cout<<"TAK\n";
else cout<<"NIE\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
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: 96ms
memory: 6500kb
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'