QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#775346 | #9786. Magical Bags | ucup-team5697# | WA | 1ms | 6008kb | C++14 | 1.2kb | 2024-11-23 15:35:28 | 2024-11-23 15:35:29 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;bool Mbe;
namespace MAOJUN{
typedef pair<int,int> pi;
const int N=2e5+5;
int n,V=0,d[N*2],s[N*2];
pi a[N];bool vs[N];
#define fi first
#define se second
inline void main(){
scanf("%d",&n);
int sum=0;
for(int i=1,k,x;i<=n;i++){
scanf("%d",&k);
int l=1e9,r=0;
while(k--){scanf("%d",&x);l=min(l,x);r=max(r,x);}
a[i]=pi(l,r);
d[++V]=l;if(l!=r)d[++V]=r;
}
sum=V;
sort(d+1,d+V+1);
for(int i=1;i<=n;i++){
a[i].fi=lower_bound(d+1,d+V+1,a[i].fi)-d;
a[i].se=lower_bound(d+1,d+V+1,a[i].se)-d;
}
sort(a+1,a+n+1,[&](pi x,pi y){return x.fi^y.fi?x.fi>y.fi:x.se<y.se;});
int mn=1e9+1,m=0;
for(int i=1;i<=n;i++)
if(a[i].se<mn){
mn=a[i].se;
if(a[i].fi!=a[i].se)a[++m]=a[i];
}else{s[a[i].fi]++;s[a[i].se+1]--;}
for(int i=1;i<=V;i++)s[i]+=s[i-1];
n=m;sort(a+1,a+n+1);
for(int i=1,j;i<=n;i=j+1){
for(j=i;j<n&&a[j+1].fi<a[j].se;)j++;
sum-=!s[a[i].fi]||!s[a[i].se];
}
printf("%d\n",sum);
}
}bool Med;int main(){
#ifdef LOCAL
freopen("3.in","r",stdin);
freopen("data.out","w",stdout);
atexit([](){fprintf(stderr,"%dms\n%lfMB\n",clock(),(&Mbe-&Med)/1024./1024);});
#endif
MAOJUN::main();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6008kb
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: 1ms
memory: 3884kb
input:
4 1 1 1 2 1 3 1 4
output:
4
result:
ok 1 number(s): "4"
Test #3:
score: 0
Accepted
time: 0ms
memory: 6004kb
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: 0ms
memory: 3900kb
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: 1ms
memory: 5936kb
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:
186
result:
wrong answer 1st numbers differ - expected: '177', found: '186'