标签:ios play namespace second 1.2 ems make es2017 sed
1 #include<iostream> 2 #include<algorithm> 3 #include<cstdio> 4 #include<cstring> 5 #include<cmath> 6 #include<cstdlib> 7 #include<vector> 8 using namespace std; 9 typedef long long ll; 10 typedef long double ld; 11 typedef pair<int,int> pr; 12 #define rep(i,a,n) for(int i=a;i<=n;i++) 13 #define per(i,n,a) for(int i=n;i>=a;i--) 14 #define Rep(i,u) for(int i=head[u];i;i=Next[i]) 15 #define clr(a) memset(a,0,sizeof(a)) 16 #define pb push_back 17 #define mp make_pair 18 #define fi first 19 #define sc second 20 #define pq priority_queue 21 #define pqb priority_queue <int, vector<int>, less<int> > 22 #define pqs priority_queue <int, vector<int>, greater<int> > 23 #define vec vector 24 ld eps=1e-9; 25 ll pp=1000000007; 26 ll mo(ll a,ll pp){if(a>=0 && a<pp)return a;a%=pp;if(a<0)a+=pp;return a;} 27 ll powmod(ll a,ll b,ll pp){ll ans=1;for(;b;b>>=1,a=mo(a*a,pp))if(b&1)ans=mo(ans*a,pp);return ans;} 28 void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); } 29 //void add(int x,int y,int z){ v[++e]=y; next[e]=head[x]; head[x]=e; cost[e]=z; } 30 int dx[5]={0,-1,1,0,0},dy[5]={0,0,0,-1,1}; 31 ll read(){ ll ans=0; char last=‘ ‘,ch=getchar(); 32 while(ch<‘0‘ || ch>‘9‘)last=ch,ch=getchar(); 33 while(ch>=‘0‘ && ch<=‘9‘)ans=ans*10+ch-‘0‘,ch=getchar(); 34 if(last==‘-‘)ans=-ans; return ans; 35 } 36 const int N=1000000; 37 int a[N],b[N],fl[N],id[N],pi[N],qi[N],f[N],Time; 38 #include<vector> 39 vector<int> ans[600]; 40 int FUCK(int n){ 41 int nu=0; 42 for (int i=1;i<=n;i++) 43 if (!fl[i]){ 44 int p=upper_bound(b+1,b+nu+1,a[i])-b; 45 if (p==nu+1) b[++nu]=a[i],id[nu]=i; 46 else b[p]=a[i],id[p]=i; 47 f[i]=id[p-1]; 48 } 49 int x=id[nu],bb=0; 50 while (x!=0){ 51 pi[++bb]=x; 52 x=f[x]; 53 } 54 return bb; 55 } 56 int SHIT(int n){ 57 int nu=0; 58 for (int i=1;i<=n;i++) 59 if (!fl[i]){ 60 int p=upper_bound(b+1,b+nu+1,-a[i])-b; 61 if (p==nu+1) b[++nu]=-a[i],id[nu]=i; 62 else b[p]=-a[i],id[p]=i; 63 f[i]=id[p-1]; 64 } 65 int x=id[nu],bb=0; 66 while (x!=0){ 67 qi[++bb]=x; 68 x=f[x]; 69 } 70 return bb; 71 } 72 int main(){ 73 int n=read(),num=n; 74 for (int i=1;i<=n;i++) a[i]=read(); 75 while (num>0){ 76 ++Time; 77 int p=FUCK(n); 78 int q=SHIT(n); 79 if (p>q){ 80 num-=p; 81 for (int i=p;i>=1;i--){ 82 ans[Time].push_back(a[pi[i]]); fl[pi[i]]=1; 83 } 84 } else { 85 num-=q; 86 for (int i=q;i>=1;i--){ 87 ans[Time].push_back(a[qi[i]]); fl[qi[i]]=1; 88 } 89 } 90 } 91 printf("%d\n",Time); 92 for (int i=1;i<=Time;i++){ 93 int size=ans[i].size(); 94 printf("%d ",size); 95 for (int j=0;j<size-1;j++) 96 printf("%d ",ans[i][j]); 97 printf("%d\n",ans[i][size-1]); 98 } 99 return 0; 100 }
标签:ios play namespace second 1.2 ems make es2017 sed
原文地址:http://www.cnblogs.com/SXia/p/7569524.html