QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#529460 | #9221. Missing Boundaries | ucup-team4717# | WA | 6ms | 10860kb | C++14 | 2.1kb | 2024-08-24 13:13:20 | 2024-08-24 13:13:20 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
namespace IO{
char buff[1<<21],*p1=buff,*p2=buff;
char getch(){
return p1==p2&&(p2=((p1=buff)+fread(buff,1,1<<21,stdin)),p1==p2)?EOF:*p1++;
}
template<typename T>
void read(T &x){
char ch=getch();int fl=1;x=0;
while(ch>'9'||ch<'0'){if(ch=='-')fl=-1;ch=getch();}
while(ch<='9'&&ch>='0'){x=x*10+ch-48;ch=getch();}
x*=fl;
}
template<typename T,typename ...Args>
void read(T &x,Args& ...args){
read(x);read(args...);
}
char obuf[1<<21],*p3=obuf;
void putch(char ch){
if(p3-obuf<(1<<21))*p3++=ch;
else fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=ch;
}
char ch[100];
template<typename T>
void write(T x){
if(!x)return putch('0');
if(x<0)putch('-'),x*=-1;
int top=0;
while(x)ch[++top]=x%10+48,x/=10;
while(top)putch(ch[top]),top--;
}
template<typename T,typename ...Args>
void write(T x,Args ...args){
write(x);write(args...);
}
void flush(){fwrite(obuf,p3-obuf,1,stdout);}
}
using namespace IO;
const int N=1e5+5;
int n,m,cnt,L;
struct node{
int l,r;
int opsl,opsr;
}a[N];
void sol(){
cnt=0;
read(n,L);m=0;
for(int i=1;i<=n;i++){
int l,r;
read(l,r);
if(l==-1&&r==-1)cnt++;
else if(l==-1)a[++m]=node{r,r,0,1};
else if(r==-1)a[++m]=node{l,l,1,0};
else a[++m]=node{l,r,1,1};
}
sort(a+1,a+m+1,[](node A,node B){return A.l<B.l;});
int sum=0;
for(int i=2;i<=m;i++){
if(a[i].l<=a[i-1].r){
putch('N'),putch('I'),putch('E'),putch('\n');
return;
}
sum+=a[i].r-a[i].l+1;
}
if(L-sum<cnt){
putch('N'),putch('I'),putch('E'),putch('\n');
return;
}
if(a[1].l>1&&a[1].opsl==1)cnt--;
if(a[m].r<L&&a[m].opsr==1)cnt--;
for(int i=2;i<=n;i++)
if(a[i-1].r<a[i].l-1&&a[i-1].opsr==1&&a[i].opsl==1)cnt--;
if(cnt<0){
putch('N'),putch('I'),putch('E'),putch('\n');
return;
}else{
putch('T'),putch('A'),putch('K'),putch('\n');
return;
}
}
signed main(){
int T;
read(T);
while(T--)sol();
flush();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7796kb
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: 6ms
memory: 10860kb
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'