//\\__ hr1212 __//\\
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 1000100
#define MOD 1000000007
#define F first
#define S second
int n,m,dp[1010],p[1010];
vector<pair<pii ,int> > v;
vi w;
void solve(int x){
if(x==-1)
return;
w.pb(x);
solve(p[x]);
}
int cmp(pair<pii ,int> p,pair<pii ,int> q){
if(p.F.F!=q.F.F)
return p.F.F<q.F.F;
return p.F.S<q.F.S;
}
int main(){
int r,k,i,c=0,x=0,y=0,j,t,l,z,x1=0,y1=0;
ll ans=0;
i=0;
while(sii(n,m)!=EOF){
v.pb(mp(mp(n,m),i));
i++;
}
sort(all(v),cmp);
n=v.size();
clr(dp,0);
clr(p,-1);
f(i,0,n){
f(j,0,i){
if(v[i].F.F>v[j].F.F && v[i].F.S<v[j].F.S){
if(dp[j]+1>dp[i]){
dp[i]=dp[j]+1;
p[i]=j;
}
}
}
}
z=-1;
f(i,0,n)
if(dp[i]>z){
z=dp[i];
c=i;
}
z++;
pi(z);
solve(c);
reverse(all(w));
f(i,0,w.size())
pi(v[w[i]].S+1);
return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mi;
#define si(a) scanf("%d",&a)
#define sii(a,b) scanf("%d %d",&a,&b)
#define siii(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pi(a) printf("%d\n",a)
#define nl printf("\n");
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define f(i,a,b) for(i=a;i<b;i++)
#define rf(i,a,b) for(i=a;i>=b;i--)
#define clr(x,a) memset(x,a,sizeof(x))
#define MAX 1000100
#define MOD 1000000007
#define F first
#define S second
int n,m,dp[1010],p[1010];
vector<pair<pii ,int> > v;
vi w;
void solve(int x){
if(x==-1)
return;
w.pb(x);
solve(p[x]);
}
int cmp(pair<pii ,int> p,pair<pii ,int> q){
if(p.F.F!=q.F.F)
return p.F.F<q.F.F;
return p.F.S<q.F.S;
}
int main(){
int r,k,i,c=0,x=0,y=0,j,t,l,z,x1=0,y1=0;
ll ans=0;
i=0;
while(sii(n,m)!=EOF){
v.pb(mp(mp(n,m),i));
i++;
}
sort(all(v),cmp);
n=v.size();
clr(dp,0);
clr(p,-1);
f(i,0,n){
f(j,0,i){
if(v[i].F.F>v[j].F.F && v[i].F.S<v[j].F.S){
if(dp[j]+1>dp[i]){
dp[i]=dp[j]+1;
p[i]=j;
}
}
}
}
z=-1;
f(i,0,n)
if(dp[i]>z){
z=dp[i];
c=i;
}
z++;
pi(z);
solve(c);
reverse(all(w));
f(i,0,w.size())
pi(v[w[i]].S+1);
return 0;
}
No comments:
Post a Comment