zoukankan      html  css  js  c++  java
  • Luogu 2575 高手过招-SG函数

    Solution

    SG函数跑一遍就过了ouo

    Code

     1 #include<cstring>
     2 #include<cstdio>
     3 #include<algorithm>
     4 #define rd read()
     5 #define cl(a) memset(a, 0, sizeof(a));
     6 using namespace std;
     7 
     8 const int N = 1 << 21;
     9 
    10 int SG[N], S[500];
    11 int T, n;
    12 
    13 int read() {
    14     int X = 0, p = 1; char c = getchar();
    15     for(; c > '9' ||  c < '0'; c = getchar()) if(c == '-') p = -1;
    16     for(; c >= '0' && c <= '9'; c = getchar()) X = X * 10 + c - '0';
    17     return X * p;
    18 }
    19 
    20 void mkSG() {
    21     for(int i = 0; i < 20; ++i) SG[i] = 0;
    22     for(int i = 1; i < (1 << 20); ++i) {
    23         cl(S);
    24         int last = -1, nt;
    25         for(int j = 0; j < 20; ++j) if((i >> j) & 1) {
    26             if(~last) {
    27                 nt = i | (1 << last);
    28                 nt ^= 1 << j;
    29                 S[SG[nt]] = 1;
    30             }
    31         } else last = j;
    32         int j = 0;
    33         for(; S[j]; ++j);
    34         SG[i] = j;
    35     }
    36 }
    37 
    38 int main()
    39 {
    40     mkSG();
    41     T = rd;
    42     for(; T; T--) {
    43         n = rd;
    44         int ans = 0;
    45         for(int i = 1; i <= n; ++i) {
    46             int m = rd, tmp = 0;
    47             for(int j = 1; j <= m; ++j) {
    48                 int x = rd;
    49                 tmp |= 1 << (20 - x);    
    50             }
    51             ans ^= SG[tmp];
    52         }
    53         if(ans) puts("YES");
    54         else puts("NO");
    55     }
    56 }
    View Code
  • 相关阅读:
    [转载]setup factory使用方法
    MFC中调用WPF教程
    Reduce the Number of SQL Statements
    Library Cache Hit Ratio
    Seconds in wait
    PX Deq: Execute Reply等待事件
    RoundTrip Time
    Changing an Init.ora Parameter
    PX qref latch等待事件
    提高DBWR进程的吞吐量
  • 原文地址:https://www.cnblogs.com/cychester/p/9606644.html
Copyright © 2011-2022 走看看