QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#562743 | #9221. Missing Boundaries | Purslane# | RE | 0ms | 3624kb | C++14 | 1.0kb | 2024-09-13 20:24:27 | 2024-09-13 20:24:27 |
Judging History
answer
#include<bits/stdc++.h>
#define ffor(i,a,b) for(int i=(a);i<=(b);i++)
#define roff(i,a,b) for(int i=(a);i>=(b);i--)
using namespace std;
const int MAXN=30000+10;
int T,n,len,l[MAXN],r[MAXN];
int main() {
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>T;
while(T--) {
cin>>n>>len;
ffor(i,1,n) cin>>l[i]>>r[i];
map<int,int> pre,tp;
int free=0;
ffor(i,1,n) {
if(l[i]==-1&&r[i]==-1) free++;
else {
if(l[i]==-1) tp[r[i]]=2,pre[r[i]]++,pre[r[i]+1]--;
else if(r[i]==-1) tp[l[i]]=1,pre[l[i]]++,pre[l[i]+1]--;
else tp[l[i]]=tp[r[i]]=3,pre[l[i]]++,pre[r[i]+1]--;
}
}
pre[len+1]+=0,pre[1]+=0;
int sum=0,flg=0,must=0,most=0;
for(auto it=pre.begin();it!=pre.end();it++) {
if(it==--pre.end()) continue ;
sum+=it->second;
int L=it->first,R=(next(it)->first)-1;
if(sum>=2) flg=1;
else if(sum==0) {
most+=R-L+1;
if(tp[L-1]!=1&&tp[R+1]!=2) must++;
}
}
if(!flg&&must<=free&&free<=most) cout<<"TAK\n";
else cout<<"NIE\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
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
Runtime Error
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 ...