QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#773754 | #9786. Magical Bags | ucup-team4454# | WA | 2ms | 12292kb | C++14 | 1.4kb | 2024-11-23 10:15:03 | 2024-11-23 10:15:06 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int read(){
int ret=0,flg=0;
char c=getchar();
while(c<'0'||c>'9')flg|=c=='-',c=getchar();
while(c>='0'&&c<='9')ret=(ret<<3)+(ret<<1)+c-'0',c=getchar();
return flg?-ret:ret;
}
inline void write(int x,bool flg){
char a[21];
if(!x)putchar('0');
if(x<0)putchar('-'),x=-x;
int cnt=0;
while(x){
a[++cnt]=x%10+'0';
x/=10;
}
while(cnt)putchar(a[cnt--]);
putchar(flg?'\n':' ');
return ;
}
#define maxn 200010
int n,px[maxn],pn[maxn],sx[maxn],sn[maxn];
int l[maxn],r[maxn];
vector<int> v[maxn];
int main(){
n=read();
px[0]=1e9;
for(int i=1;i<=n;i++){
int k=read();
l[i]=1e9,r[i]=0;
for(int j=1;j<=k;j++){
int x=read();
l[i]=min(l[i],x);
r[i]=max(r[i],x);
v[i].push_back(x);
}
px[i]=min(px[i-1],r[i]);
pn[i]=max(pn[i-1],l[i]);
}
sx[n+1]=1e9,sn[n+1]=0;
if(pn[n]>px[n]){
write(n,1);
return 0;
}
for(int i=n;i;i--){
int L=max(pn[i-1],sn[i+1]),R=min(px[i-1],sx[i+1]);
for(auto t:v[i]){
if(t<=R&&t>=L){
write(2*n-1,1);
return 0;
}
}
sx[i]=min(sx[i+1],r[i]);
sn[i]=max(sn[i+1],l[i]);
}
write(2*n,1);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 9376kb
input:
4 3 4 7 10 2 1 9 4 11 2 8 14 3 6 12 13
output:
7
result:
ok 1 number(s): "7"
Test #2:
score: 0
Accepted
time: 0ms
memory: 12292kb
input:
4 1 1 1 2 1 3 1 4
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 2ms
memory: 11308kb
input:
4 3 4 7 10 2 1 9 4 11 2 8 14 3 6 12 13
output:
7
result:
ok 1 number(s): "7"
Test #4:
score: 0
Accepted
time: 2ms
memory: 11328kb
input:
4 1 1 1 2 1 3 1 4
output:
4
result:
ok 1 number(s): "4"
Test #5:
score: -100
Wrong Answer
time: 2ms
memory: 10976kb
input:
100 4 372861091 407948190 424244630 359746969 6 568180757 527358812 494745349 665803213 674832670 586694351 4 696340797 775899164 919971335 716827187 4 123145962 344250363 122030550 251739234 4 342654413 368648894 150539766 255189030 1 194505887 3 755984448 736803561 745474041 4 709314938 498953418 ...
output:
100
result:
wrong answer 1st numbers differ - expected: '177', found: '100'