QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#455430#8528. ChordsPhantomThresholdWA 1ms5688kbC++201.0kb2024-06-26 14:00:052024-06-26 14:00:05

Judging History

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

  • [2024-06-26 14:00:05]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5688kb
  • [2024-06-26 14:00:05]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
using namespace std;

inline void up(int &a,const int &b){ if(a<b)a=b; }
const int maxn = 210000;

int n;
int a[maxn];

vector<int>f[maxn];
void upd(int i,int j,int c)
{
	if( (int)f[i].size()-1 <j )
		f[i].resize(j+1);
	f[i][j]=c;
}
void fix(int i)
{
	for(int j=(int)f[i].size();j>0;j--)
	{
		up(f[i][j-1],f[i][j]);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int l,r; cin>>l>>r;
		a[r]=l;
	}
	n<<=1;
	
	/*
	f[l][r]= max( f[l][l'] + 1 + f[l'][r'] )
	*/
	int ans=0;
	f[1].push_back(2);
	for(int i=2;i<=n;i++)
	{
		f[i]=f[i-1];
		f[i][0]=i+1;
		if(a[i] && a[i]<i)
		{
			int L=a[i]-1;
			int c=1;
			for(int j=(int)f[i-1].size()-1;j>=0;j--) if(f[i-1][j]>L)
			{
				c+=j;
				break;
			}
			
			upd(i,c,a[i]);
			if(L)
			{
				for(int j=1;j< (int)f[L].size() ;j++)
					upd(i,c+j,f[L][j]);
			}
		}
		fix(i);
		up(ans,(int)f[i].size()-1);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

1
1 2

output:

1

result:

ok 1 number(s): "1"

Test #3:

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

input:

2
1 3
2 4

output:

1

result:

ok 1 number(s): "1"

Test #4:

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

input:

2
1 4
2 3

output:

2

result:

ok 1 number(s): "2"

Test #5:

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

input:

3
3 5
1 4
2 6

output:

2

result:

ok 1 number(s): "2"

Test #6:

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

input:

4
2 7
1 6
3 8
4 5

output:

2

result:

ok 1 number(s): "2"

Test #7:

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

input:

6
8 9
6 7
4 10
1 5
11 12
2 3

output:

5

result:

ok 1 number(s): "5"

Test #8:

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

input:

9
2 8
10 17
9 15
1 12
6 14
3 13
4 11
5 7
16 18

output:

4

result:

ok 1 number(s): "4"

Test #9:

score: -100
Wrong Answer
time: 1ms
memory: 3624kb

input:

13
8 16
2 13
14 23
10 11
7 17
6 24
12 18
9 20
4 15
19 21
3 26
1 25
5 22

output:

7

result:

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