QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#456443#8528. Chordsucup-team1525WA 2ms9244kbC++14820b2024-06-27 23:24:482024-06-27 23:24:49

Judging History

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

  • [2024-06-27 23:24:49]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:9244kb
  • [2024-06-27 23:24:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n;
const int N=100005;
int a[N*2];
vector<int> f[N*2];
int getans(int l,int r)
{
    for (int i=0;i<(int)f[r].size();++i)
        if (l>f[r][i])
            return i;
    return f[r].size();
}
int main()
{
    scanf("%d",&n);
    for (int i=1,u,v;i<=n;++i)
    {
        scanf("%d%d",&u,&v);
        a[v]=u;
    }
    for (int i=2;i<=n*2;++i)
    {
        f[i]=f[i-1];
        if (!a[i])
            continue;
        int p=getans(i-1,a[i]+1);
        if (p+f[a[i]-1].size()+1>f[i].size())
            f[i].resize(p+f[a[i]-1].size()+1,-1);
        f[i][p]=max(f[i][p],a[i]);
        for (int j=0;j<f[a[i]-1].size();++j)
            f[i][p+j+1]=max(f[i][p+j+1],f[a[i]-1][j]);
    }
    printf("%d\n",(int)f[n*2].size());
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 8416kb

input:

5
1 2
4 10
7 9
3 5
6 8

output:

3

result:

ok 1 number(s): "3"

Test #2:

score: 0
Accepted
time: 0ms
memory: 8808kb

input:

1
1 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

score: 0
Accepted
time: 2ms
memory: 9244kb

input:

2
1 3
2 4

output:

1

result:

ok 1 number(s): "1"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 8612kb

input:

2
1 4
2 3

output:

1

result:

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