link:http://codeforces.com/problemset/problem/4/D

 #include <iostream>
 #include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <cmath>
 #include <cctype>
 #include <algorithm>
 #include <queue>
 #include <deque>
 #include <queue>
 #include <list>
 #include <map>
 #include <set>
 #include <vector>
 #include <utility>
 #include <functional>
 #include <fstream>
 #include <iomanip>
 #include <sstream>
 #include <numeric>
 #include <cassert>
 #include <ctime>
 #include <iterator>
 const int INF = 0x3f3f3f3f;
 ][] = {{-,},{,},{,-},{,},{-,-},{-,},{,-},{,}};
 using namespace std;
 ],path[],End;
 bool flag;
 typedef struct node
 {
     int W,H,In;
     bool operator < (const node &other) const
     {
         if(W!=other.W) return W<other.W;
         else return H<other.H;
     }
 }node;
 node ma[];
 bool judge(node a,node b)
 {
     if(a.W<b.W&&a.H<b.H) return true; else return false;
 }
 void print_ans(int i)
 {
     ) return;
     print_ans(path[i]);
     printf();
 }
 int main(void)
 {
     #ifndef ONLINE_JUDGE
     freopen("in.txt", "r", stdin );
     #endif // ONLINE_JUDGE

     while(~scanf("%d%d%d",&n,&w,&h))
     {
         flag=;
         ;i<n;++i)
         {
             int a,b;
             scanf("%d%d",&a,&b);
             if(a<=w||b<=h) continue;
             flag=true; ma[cnt].W=a; ma[cnt].H=b; ma[cnt].In=i;
             cnt++;
         }
         if(!flag)
         {
             printf("0\n"); continue;
         }
         sort(ma,ma+cnt);
         ans=;
         memset(d,,sizeof(d));
         memset(path,-,sizeof(path));
         End=;
         ;i<cnt;++i) d[i]=;
         ;i<cnt;++i)
         {
             ;
             ;j<i;++j)
             {
                 if(judge(ma[j],ma[i]))
                 {
                     if(tmp<d[j])
                     {
                         tmp=d[j]; path[i]=j;
                     }
                 }
             }
             d[i]=tmp+;
             if(ans<d[i])
             {
                 ans=d[i]; End=i;
             }
         }
         printf("%d\n",ans);
         print_ans(End);
         printf("\n");
 //        printf("%d\n",ma[End-1].In+1);
     }

     ;
 }

最长上升子序列还写这么挫哦

这两天沉迷于kpw……囧

05-08 15:08