比赛 |
CSP2022普及组 |
评测结果 |
AAAAAAAEEEAAAAAEEEEE |
题目名称 |
上升点列 |
最终得分 |
60 |
用户昵称 |
liuyiche |
运行时间 |
1.626 s |
代码语言 |
C++ |
内存使用 |
15.02 MiB |
提交时间 |
2022-10-29 17:56:15 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int a[201][201];
int b[201][201][101];
int n, k, Max = -1;
struct point
{
int x, y;
};
inline int search(int x, int y, int c)
{
if (b[x][y][c] == -1)
{
b[x][y][c] = 0;
if (a[x+1][y] == 1)
b[x][y][c] = max(search(x+1,y,c),b[x][y][c]);
else if (c < k)
b[x][y][c] = max(search(x+1,y,c+1),b[x][y][c]);
if (a[x][y+1] == 1)
b[x][y][c] = max(search(x,y+1,c),b[x][y][c]);
else if (c < k)
b[x][y][c] = max(search(x,y+1,c+1),b[x][y][c]);
b[x][y][c] += 1;
}
return b[x][y][c];
}
int main()
{
freopen("csp2022pj_point.in","r",stdin);
freopen("csp2022pj_point.out","w",stdout);
cin >> n >> k;
for (int i = 1; i <= 200; ++i)
for (int j = 1; j <= 200; ++j)
a[i][j] = 0;
for (int i = 1; i <= 200; ++i)
for (int j = 1; j <= 200; ++j)
for (int l = 0; l <= k; ++l)
b[i][j][l] = -1;
vector<point> v(n+1);
for (int i = 1; i <= n; ++i)
{
cin >> v[i].x >> v[i].y;
a[v[i].x][v[i].y] = 1;
}
for (int i = 1; i <= n; ++i)
Max = max(search(v[i].x,v[i].y,0),Max);
cout << Max;
return 0;
}