比赛 CSP2022普及组 评测结果 AWAATAATTTATTTTTTTTT
题目名称 上升点列 最终得分 30
用户昵称 空条承太郎& 运行时间 13.348 s
代码语言 C++ 内存使用 4.02 MiB
提交时间 2022-10-29 17:56:27
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
int n,m;
struct node{
    long long x,y;
    bool operator< (const node& o)const{
        if(x != o.x)return x<o.x;
        else return y < o.y;
    }
}k[550],la;
long long ans=1;
void dfs(int g,long long nu,long long len){
    if(g>n){
        if(len+nu>ans)
        ans = len+nu;
        return;
    }
    for (int i = g; i <= n; ++i){
        if(k[i].x>=la.x&&k[i].y>=la.y){
            long long run = k[i].x-la.x+k[i].y-la.y-1;
            if(run<=nu){
                node kk=la;
                la = {k[i].x,k[i].y};
                dfs(i+1,nu-run,len+run+1);
                la = kk;
            }
            else dfs(n+1,0,len+nu);
        }
    }
}
int main(){
	freopen("csp2022pj_point.in","r",stdin);
	freopen("csp2022pj_point.out","w",stdout);
    cin>>n>>m;
    for (int i = 1; i <= n; ++i){
        cin>>k[i].x>>k[i].y;
    }
    sort(k+1,k+1+n);
    for (int i = 1; i <= n; ++i){
        la = {k[i].x,k[i].y};
        dfs(i+1,m,1);
    }
    cout<<ans;
    return  0;
}