zoukankan      html  css  js  c++  java
  • LibreOJ #524. 「LibreOJ β Round #4」游戏

    二次联通门 : LibreOJ #524. 「LibreOJ β Round #4」游戏

    /*
        LibreOJ #524. 「LibreOJ β Round #4」游戏
        
        找找规律就会发现。。
        当有X的时候,答案跟X个数的奇偶有关
        否则就求一下逆序对就好了。。
    
        由于SB的错误。。WA了3发才过
        然后就签完到走人了
    */
    #include <cstdio>
    #include <iostream>
    #include <cstring>
    #include <algorithm>
    
    #define Max 11
    
    int key[Max * 10000], rank[Max * 10000];
    int s[Max * 10000];
    
    int Main ()
    {
        int N, x; scanf ("%d", &N); register int i, j;
        static char l[Max];     int C = 0, cur = 0 ; bool f;
        if (N == 1) return printf ("L"), 0;
        for (i = 1; i <= N; ++ i)
        {
            scanf ("%s", l); f = false, x = 0;
            if (l[0] == 'X') ++ C;
            else
            {
                int Len = strlen (l);
                if (l[0] == '-') 
                {
                    f = true;
                    for (j = 1; j < Len; ++ j)
                        if (isdigit (l[j]))
                            x = x * 10 + l[j] - '0';
                }
                else 
                {
                    for (j = 0; j < Len; ++ j)
                        if (isdigit (l[j]))
                            x = x * 10 + l[j] - '0';
                }
                key[++ cur] = f ? -x : x;
                rank[cur] = key[cur];
            }
        }    
        if (C) return printf (C % 2 ? "W" : "L"), 0;
        long long Answer = 0; int Size;
        std :: sort (key + 1, key + 1 + cur);
        Size = std :: unique (key + 1, key + 1 + cur) - key - 1;
        for (i = 1; i <= cur; ++ i)
        {
            rank[i] = std :: lower_bound (key + 1, key + 1 + Size, rank[i]) - key;
            int res = 0;
            for (j = rank[i]; j <= cur; j += j & -j) ++ s[j];
            for (j = rank[i]; j; j -= j & -j) res -= s[j];
            for (j = cur; j; j -= j & -j) res += s[j];
            Answer += res;
        }
        printf (Answer % 2 ? "W" : "L");
    
        return 0;
    }
    
    int ZlycerQan = Main ();
    int main (int argc, char *argv[]) {;}
  • 相关阅读:
    Aapache Tomcat AJP 文件包含漏洞(CVE-2020-1938)
    Tomcat 任意文件上传漏洞(CVE-2017-12615)
    Apache Shiro 1.2.4反序列化漏洞(CVE-2016-4437)
    Redis 4.x/5.x 未授权访问漏洞
    mysql 5.7关于group by显示多列的一个潜坑
    Python
    购物车作业
    Lesson2
    a good website to test OTP
    利用fidder发送request
  • 原文地址:https://www.cnblogs.com/ZlycerQan/p/7468002.html
Copyright © 2011-2022 走看看