QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#529865 | #9221. Missing Boundaries | ucup-team1525# | WA | 142ms | 27116kb | C++17 | 1.4kb | 2024-08-24 14:13:56 | 2024-08-24 14:13:56 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=2e5;
int n,L;
int l[N+5],r[N+5];
int pos[N*2+5],tot;
void solve(){
scanf("%d %d",&n,&L);
int cnt=0;
tot=0;
unordered_map<int,int> fl,fr;
for(int i=1;i<=n;i++){
scanf("%d %d",&l[i],&r[i]);
if(l[i]==-1&&r[i]==-1){
cnt++;
}
else{
if(l[i]!=-1){
pos[++tot]=l[i];
fl[l[i]]=i;
}
if(r[i]!=-1){
if(l[i]!=r[i])
pos[++tot]=r[i];
fr[r[i]]=i;
}
}
}
pos[++tot]=L+1;
sort(pos,pos+1+tot);
for(int i=1;i<tot;i++)
if(pos[i]==pos[i+1]){
puts("NIE");
return;
}
fr[0]=0; fl[L+1]=n+1;
for(int i=1;i<tot;i++){
if(fr[pos[i]]){
int x=fr[pos[i]];
if(l[x]!=-1){
if(l[x]!=pos[i]&&l[x]!=pos[i-1]){
puts("NIE");
return;
}
}
}
}
int cl=0,cr=0;
for(int i=1;i<=tot;i++){
int pl=pos[i-1],pr=pos[i];
if(fl[pl]&&fl[pl]==fr[pr]) continue;
if(fr[pl]&&fl[pr]){
cl+=pr-pl-1;
}
cr+=pr-pl-1;
}
puts(cl<=cnt&&cr>=cnt?"TAK":"NIE");
}
int main(){
int t; scanf("%d",&t);
while(t--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6024kb
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: 142ms
memory: 27116kb
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: 3664kb
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: 99ms
memory: 25568kb
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'