貪心場次
密碼:996996
有點思維
#include#define il inline
#define pb push_back
#define fi first
#define se second
#define ms(_data,v) memset(_data,v,sizeof(_data))
#define sc(n) scanf("%d",&n)
#define sc(n,m) scanf("%d %d",&n,&m)
#define sz(a) int((a).size())
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
int t;
int main()a[maxn];
bool cmp(node x,node y)
int main() a[maxn];
bool cmp(node x,node y)
sort(a+1,a+n+1,cmp);
int ans=1;
double np=a[1].r;
rep(i,2,n)
} cout《離散化+尺取
#include#define il inline
#define pb push_back
#define fi first
#define se second
#define ms(_data,v) memset(_data,v,sizeof(_data))
#define sc(n) scanf("%d",&n)
#define sc(n,m) scanf("%d %d",&n,&m)
#define sz(a) int((a).size())
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
const int maxn=1e6+5;
int t,n,a[maxn],b[maxn];
int vis[maxn];
int main()
ans=max(ans,r-l+1);
vis[a[++r]]++;
} cout《把x和y分開了考慮,用y從小到大排序。
#include#define il inline
#define pb push_back
#define fi first
#define se second
#define ms(_data,v) memset(_data,v,sizeof(_data))
#define sc(n) scanf("%d",&n)
#define sc(n,m) scanf("%d %d",&n,&m)
#define sz(a) int((a).size())
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
const int maxn=1e5+5;
int n,ax[maxn],ay[maxn];
struct node x[maxn],y[maxn];
bool cmp(node x,node y)
bool fg=0;
sort(x+1,x+n+1,cmp);
rep(i,1,n)
}if(j>x[i].r)
} if(fg) cout<<"impossible"}
if(fg) cout<<"impossible"《暴力,列舉每乙個點為起始點,貪心交換
#include#define il inline
#define pb push_back
#define fi first
#define se second
#define ms(_data,v) memset(_data,v,sizeof(_data))
#define sc(n) scanf("%d",&n)
#define sc(n,m) scanf("%d %d",&n,&m)
#define sz(a) int((a).size())
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
const int maxn=1e3+5;
int n,a[maxn],p[maxn],b[maxn];
il int solve(int st)
return res;
}il int solve2(int st)
cout《數形結合基礎題,可是不會啊 可以先看這個 傳送門
#include#define il inline
#define pb push_back
#define fi first
#define se second
#define ms(_data,v) memset(_data,v,sizeof(_data))
#define sc(n) scanf("%d",&n)
#define sc(n,m) scanf("%d %d",&n,&m)
#define sz(a) int((a).size())
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define drep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const double pi=acos(-1.0);
const double eps=1e-9;
const int maxn=1e5+5;
int t,n,l,sum[maxn],que[maxn];
string s;
il double getk(int x,int y)
int main()
} cout<} return 0;
}
紫書訓練 7 16
差分約束 cdq分治 虛樹 密碼 996996 差分約束的部落格 虛樹部落格 虛樹還沒有學習 差分約數裸題 include include include include include include include include include include include define i...
巢狀矩形(DAG模型) 紫書訓練
題目描述 有n個矩形,每個矩形可以用a,b來描述,表示長和寬。矩形x a,b 可以巢狀在矩形y c,d 中當且僅當a紫書上有題目,但是沒有寫題出自 只好自己大致寫一下題目了.做題感受 經典的dp問題,但是由於我剛入門dp並不能特別快理解,想出來了還好說。思路 狀態轉移方程d i max.d i 表示...
紫書 STL初步
檢索 int p lower bound a,a n,x a 因為是返回位置所以要減掉起始位置 vector 不定長陣列 a.size 讀大小,a.resize 改變大小,a.push back 向尾部新增元素,a.pop back 刪除最後乙個元素 empty 測試是否為空 vector是模板類 ...