记录编号 392095 评测结果 AAAAAAAAAA
题目名称 [HAOI 2015]数组游戏 最终得分 100
用户昵称 Gravatarsxysxy 是否通过 通过
代码语言 C++ 运行时间 2.243 s
提交时间 2017-04-07 08:05:42 内存使用 11.73 MiB
显示代码纯文本
#include <cstdio>
#include <cstring>
#include <cstdarg>
#include <list>
#include <queue>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
const int MAXN = 1e6+10;
int n;
int sg[MAXN], _sg[MAXN], vis[MAXN], vist;
inline int SG(int x){return x < MAXN?sg[x]:_sg[n/x];}
void dfs(int x){
  if(SG(x))return;
  for(int i = 2, j; i <= x; i = j+1){
    j = x/(x/i);
    dfs(x/i);
  }
  vis[0] = ++vist;
  int cur = 0, ans = 0;
  for(int i = 2, j; i <= x; i = j+1){
    j = x/(x/i);
    int sg = SG(x/i);
    vis[cur^sg] = vist;
    if((j-i+1)&1)cur ^= sg;
  }
  while(vis[ans] == vist)ans++; //m
  if(x < MAXN)sg[x] = ans; else _sg[n/x] = ans;
}
int main(){
  freopen("haoi2015_t3.in", "r", stdin);
  freopen("haoi2015_t3.out", "w", stdout);
  int T;
  scanf("%d %d", &n, &T);
  dfs(n);
  while(T--){
    int sum = 0, k, x;
    scanf("%d", &k);
    while(k--){
      int x; scanf("%d", &x);
      sum ^= SG(n/x);
    }
    puts(sum?"Yes":"No");
  }
  return 0;
}