QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#529137 | #9221. Missing Boundaries | ucup-team3282# | WA | 101ms | 8336kb | C++20 | 1.8kb | 2024-08-24 09:55:59 | 2024-08-24 09:56:00 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
pair<long long,long long>x[10000050];
bool cmp(pair<long long ,long long>a,pair<long long,long long>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(){
long long t;cin>>t;while(t--){
bool flag=1;
long long L,n;cin>>n>>L;
long long cnt=0,rdd=0;
for(long long 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;
long long lst=0,op=0;
for(long long i=1;i<=n;i++){
if(!x[i].first){
if(x[i].second<=lst)flag=0;
}
else{
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";
}
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3576kb
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: 101ms
memory: 8336kb
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'