标签:-- blog str inline nbsp node getc ++i freopen
#include <algorithm> #include <cstdio> #include <cctype> #include <vector> #define N 100005 using namespace std; vector<int>ans[N/10]; inline void Read(int &x) { register char ch=getchar(); for(x=0;!isdigit(ch);ch=getchar()); for(;isdigit(ch);x=x*10+ch-‘0‘,ch=getchar()); } struct node { int y0,m0,d0,y1,m1,d1,x; bool operator<(node a)const { return x<a.x; } }Joob[N]; struct nodee { int y,m,d,id; bool operator<(nodee a)const { if(y==a.y) { if(m==a.m) return d<a.d; else return m<a.m; } else return y<a.y; } }Query[N]; int Que[N],h=0,cnt=0,n,m; void Inssort(int l) { int i,j,key; for(i=1;i<l;++i) { key=Que[i]; for(j=i-1;j>=1;--j) if(Que[j]>key) Que[j+1]=Que[j]; else break; Que[j+1]=key; } } int Main() { freopen("1.in","r",stdin); scanf("%d",&n); for(int i=1;i<=n;++i) { Read(Joob[++cnt].y0); Read(Joob[cnt].m0); Read(Joob[cnt].d0); Read(Joob[cnt].y1); Read(Joob[cnt].m1); Read(Joob[cnt].d1); Read(Joob[cnt].x); if(Joob[cnt].y0>Joob[cnt].y1) cnt--; else if(Joob[cnt].m0+1==Joob[cnt].m1&&Joob[cnt].d0>Joob[cnt].d1) cnt--; else if(Joob[cnt].m0==Joob[cnt].m1) cnt--; } sort(Joob+1,Joob+1+cnt); scanf("%d",&m); for(int i=1;i<=m;++i) Read(Query[i].y),Read(Query[i].m),Read(Query[i].d),Query[i].id=i; // sort(Query+1,Query+1+m); int j=1,last=1; for(int i=1;i<=m;++i) { for(int j=1;j<=cnt;++j) { if(Joob[j].y0<Query[i].y&&Query[i].y<Joob[j].y1) Que[++h]=Joob[j].x; else if(Joob[j].y0==Query[i].y) { if(Joob[j].m0<Query[i].m) Que[++h]=Joob[j].x; else if(Joob[j].m0==Query[i].m&&Joob[j].d0<=Query[i].d) Que[++h]=Joob[j].x; } else if(Joob[j].y1==Query[i].y) { if(Joob[j].m1>Query[i].m) Que[++h]=Joob[j].x; else if(Joob[j].m1==Query[i].m&&Joob[j].d1>=Query[i].d) Que[++h]=Joob[j].x; } } printf("%d",h); for(int p=1;p<=h;++p) printf(" %d",Que[p]); h=0; printf("\n"); } return 0; } int sb=Main(); int main(int argc,char *argv[]){;}
标签:-- blog str inline nbsp node getc ++i freopen
原文地址:http://www.cnblogs.com/ruojisun/p/7588920.html