QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#775912#9786. Magical Bagsucup-team4770#WA 1ms5752kbC++171.1kb2024-11-23 17:02:332024-11-23 17:02:33

Judging History

你现在查看的是最新测评结果

  • [2024-11-23 17:02:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5752kb
  • [2024-11-23 17:02:33]
  • 提交

answer

//Date: 2024-11-23 14:40:13
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int rd() {
    int s=0,m=0;char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')m=1;ch=getchar();}
    while( isdigit(ch)) s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return m?-s:s;
}
bool MBE;
namespace SOLVER {
int n,sum,ss,f[200005],g[200005];struct QWQ {int l,r;} a[200005],b[200005];
bool cmp(QWQ a1,QWQ a2) {return a1.r!=a2.r?a1.r<a2.r:a1.l<a2.l;}
void MAIN() {
    cin>>n;
    for(int i=1;i<=n;i++) {
        int len=rd();a[i].l=1e9+1,a[i].r=0;
        for(int j=1,x;j<=len;j++) x=rd(),a[i].l=min(a[i].l,x),a[i].r=max(a[i].r,x);
        sum+=(len==1),ss+=min(len,2ll);
    }
    sort(a+1,a+n+1,cmp);int Mx=0;
    for(int i=1,j=0;i<=n;i++) {
        while(j<=n&&a[j].r<a[i].l) Mx=max(Mx,f[j]),j++;
        f[i]=Mx+1;
    }
    for(int i=1;i<=n;i++) Mx=max(Mx,f[i]);
    cout<<ss+sum-Mx<<endl;
}
}
bool MED;
signed main() {
    //freopen(".in","r",stdin);freopen(".out","w",stdout);
    for(int tt=1;tt;tt--) SOLVER::MAIN();
    cerr<<(&MBE-&MED)/1024<<" KB, "<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5752kb

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: 5612kb

input:

4
1 1
1 2
1 3
1 4

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 1ms
memory: 5612kb

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: 1ms
memory: 5736kb

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: 0ms
memory: 5656kb

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:

175

result:

wrong answer 1st numbers differ - expected: '177', found: '175'