codeforces 4D. Mysterious Present
来源:互联网 发布:a星算法的优缺点 编辑:程序博客网 时间:2024/05/21 08:59
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#define M 5010
using namespace std;
struct type{
int w,h,c,t,p;
}En[M];
bool cmp(type a,type b){
if(a.w==b.w)
return a.h<b.h;
else return a.w<b.w;
}
int main(){
int n,cw,ch,i,j,k,s,maxi,x,w,h;
int a[M];
while(scanf("%d %d %d",&n,&cw,&ch)!=EOF){
x=1;
for(i=1;i<=n;i++){
scanf("%d %d",&w,&h);
if(w>cw&&h>ch){
En[x].w=w;
En[x].h=h;
En[x].c=1;
En[x].t=i;
En[x++].p=0;
}
}
if(x==1)printf("0\n");
else{
x--;
sort(En+1,En+1+x,cmp);
s=1;
k=En[s].c;
maxi=s;
for(i=s+1;i<=x;i++){
for(j=1;j<i;j++){
if(En[i].w>En[j].w&&En[i].h>En[j].h){
if(En[i].c<En[j].c+1){
En[i].c=En[j].c+1;
En[i].p=j;
}
}
}
if(En[i].c>k)maxi=i,k=En[i].c;
}
printf("%d\n",k);
j=maxi;i=0;
a[i++]=En[j].t;
while(En[j].p!=0){
j=En[j].p;
a[i++]=En[j].t;
}
i--;
while(i>0)printf("%d ",a[i--]);
printf("%d\n",a[i]);
}
}
return 0;
}
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#define M 5010
using namespace std;
struct type{
int w,h,c,t,p;
}En[M];
bool cmp(type a,type b){
if(a.w==b.w)
return a.h<b.h;
else return a.w<b.w;
}
int main(){
int n,cw,ch,i,j,k,s,maxi,x,w,h;
int a[M];
while(scanf("%d %d %d",&n,&cw,&ch)!=EOF){
x=1;
for(i=1;i<=n;i++){
scanf("%d %d",&w,&h);
if(w>cw&&h>ch){
En[x].w=w;
En[x].h=h;
En[x].c=1;
En[x].t=i;
En[x++].p=0;
}
}
if(x==1)printf("0\n");
else{
x--;
sort(En+1,En+1+x,cmp);
s=1;
k=En[s].c;
maxi=s;
for(i=s+1;i<=x;i++){
for(j=1;j<i;j++){
if(En[i].w>En[j].w&&En[i].h>En[j].h){
if(En[i].c<En[j].c+1){
En[i].c=En[j].c+1;
En[i].p=j;
}
}
}
if(En[i].c>k)maxi=i,k=En[i].c;
}
printf("%d\n",k);
j=maxi;i=0;
a[i++]=En[j].t;
while(En[j].p!=0){
j=En[j].p;
a[i++]=En[j].t;
}
i--;
while(i>0)printf("%d ",a[i--]);
printf("%d\n",a[i]);
}
}
return 0;
}
- codeforces 4D. Mysterious Present
- codeforces 4D Mysterious Present
- Codeforces 4D. Mysterious Present
- codeforces 4D. Mysterious Present
- CodeForces 4D. Mysterious Present
- codeforces 4D Mysterious Present
- CodeForces 4D-Mysterious Present
- Codeforces#4D Mysterious Present
- Codeforces 4D Mysterious Present
- codeforces 4D D. Mysterious Present(dp)
- codeforces 4D Mysterious Present -- 动态规划
- CodeForces 4D Mysterious Present(DP)
- Codeforces Beta Round #4 (Div. 2 Only)D. Mysterious Present
- Codeforces Beta Round #4 (Div. 2 Only) D. Mysterious Present
- CF 4D Mysterious Present
- CF 4D Mysterious Present
- CF 4 D. Mysterious Present
- Codeforce 4D - Mysterious Present
- event机制
- SCOPE_IDENTITY、IDENT_CURRENT 和 @@IDENTITY
- 体会NSString的copy属性
- C++实现多线程读写锁
- Microwave Office 最新中文版入门教程
- codeforces 4D. Mysterious Present
- 使用sudo
- 总结--PHP篇(想点写点)
- HDU 4619 Warm up 2 最大匹配数
- 使用Grand生成ANT的Target依赖关系图
- 【String.xml】修改Android中strings.xml文件, 动态改变数据
- 游戏类别
- Oracle 补充日志
- 递归算法