记录编号 | 164512 | 评测结果 | AAAAAAAAAA | ||
---|---|---|---|---|---|
题目名称 | [HAOI 2015]数组游戏 | 最终得分 | 100 | ||
用户昵称 | 是否通过 | 通过 | |||
代码语言 | C++ | 运行时间 | 1.824 s | ||
提交时间 | 2015-06-01 20:29:34 | 内存使用 | 2.60 MiB | ||
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<vector> #include<cmath> using namespace std; int N,K,tot=0,tem=0; class miku { public: int l,r,sg; }SG[100000]; int H[300000]={0}; int get(int r) { int now=0; tem++; H[now]=tem; for(int i=tot-1;i>=0;i--) { miku s=SG[i]; int t=s.r/r-(s.l-1)/r; if(t>=1) H[now^s.sg]=tem; if(t&1) now^=s.sg; } for(int i=0;;i++) { if(H[i]!=tem) return i; } } void push(int l,int r) { miku x; x.l=l;x.r=r;x.sg=get(r); //cout<<l<<" "<<r<<" "<<x.sg<<endl; if(tot!=0&&x.sg==SG[tot-1].sg) {SG[tot-1].l=min(SG[tot-1].l,l),SG[tot-1].r=max(SG[tot-1].r,r);} else SG[tot++]=x; } void make() { int B=sqrt(N+0.5); for(int i=1;i<=B;i++) push(N/(i+1)+1,N/i); for(int i=B-1;i>=1;i--) push(i,i); } int find(int x) { for(int i=0;i<tot;i++) { if(SG[i].l<=x&&x<=SG[i].r) return SG[i].sg; } } int main() { freopen("haoi2015_t3.in","r",stdin); freopen("haoi2015_t3.out","w",stdout); scanf("%d",&N); scanf("%d",&K); make(); int p,now=0,z; for(int i=1;i<=K;i++) { now=0; scanf("%d",&z); for(int j=1;j<=z;j++) { scanf("%d",&p); now^=find(p); //cout<<find(p)<<" "; } //cout<<endl; if(now==0) printf("No\n"); else printf("Yes\n"); } return 0; }