pax
Rating
-
Bài tập
1
Điểm
1273
Rating #
-
Điểm #
18039
Giới thiệu
include<iostream>
include <ext/pb_ds/assoc_container.hpp>
include <ext/pb_ds/tree_policy.hpp>
include<math.h>
include<algorithm>
include<stdio.h>
include<map>
include<vector>
include<set>
include<iomanip>
define F first
define S second
define P system("PAUSE");
define H return 0;
define pb push_back
define mod 1000000007
using namespace std;
using namespace __gnu_pbds;
bool sc(pair<int ,int> a, pair<int,int> b)
{
if(a.F==b.F)
return b.S<a.S;
else
return a.F\<b.F;
}
typedef tree\<int,null_type,less\<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
map<pair\<int,int>,pair\<int, int>> res;
vector<pair\<int,int>> a(n),b;
for(int i=0;i<n;i++)
cin>>a[i].F>>a[i].S;
b=a;
sort(a.begin(),a.end(),greater());
set<int> luu;
luu.insert(a[0].S);
int minn,maxx;
minn=a[0].S;
for(int i=1;i<n;i++)
{
if(a[i].S>=minn)
res[a[i]].F=1;
else minn=a[i].S;
}
for(int i=0;i<n;i++)
cout<<a[i].F<<' '<<a[i].S<<endl;
sort(a.begin(),a.end(),sc);
maxx=a[0].S;
luu.clear();
luu.insert(a[0].F);
for(int i=1;i<n;i++)
{
if(a[i].S<=maxx)
res[a[i]].S=1;
else maxx=a[i].S;
}
for(int i=0;i<n-1;i++)
cout<<res[b[i]].F<<' ';
cout<<res[b[n-1]].F;
cout<<endl;
for(int i=0;i<n-1;i++)
cout<<res[b[i]].S<<' ';
cout<<res[b[n-1]].S;
}