QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212215#962. Thanks to MikeMirzayanovnamespace_stdWA 0ms3228kbC++142.4kb2023-10-13 11:54:222023-10-13 11:54:24

Judging History

This is the latest submission verdict.

  • [2023-10-13 11:54:24]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3228kb
  • [2023-10-13 11:54:22]
  • Submitted

answer

#include<cstdio>
#include<vector>
#include<algorithm>
int p[1 << 20], n;
struct protocol
{
    int tflag[1<<20];
    int rec[122][20020], recnt;
    void tFlipOnce(int l, int r, int d)
    {
        recnt++;
        for(int i = l; i <= r; i++)
            rec[d][i] = recnt;
        for(int i = l; i < r + l - i; i++)
            std::swap(p[i], p[r + l - i]);
    }
    void tFlip(int l, int r, int d)
    {
        int L = -1, rL = l;
        static int ps[1 << 20];
        int rs = 0;
        ps[0] = l;
        for(int i = l + 1; i <= r; i++)
            if(tflag[i] != tflag[i - 1])
                ps[++rs] = i;
        ps[++rs] = r + 1;
        for(int i = (tflag[l] == 0); i + 2 <= rs; i += 4)
            tFlipOnce(ps[i], ps[i + 2] - 1, d);
    }
    void pSort(int l, int r, int d)
    {
        if(l == r)
            return;
        int len = r - l + 1, lim = len >> 1;
        while(1)
        {
            int diff = 0;
            for(int i = l; i <= r; i++)
            {
                tflag[i] = (p[i] >= l + lim);
                if(i != l) diff = diff + (tflag[i] != tflag[i - 1]);
            }
            if(diff == 1 && tflag[l] == 0) break;
            tFlip(l, r, d);
            d++;
        }
        pSort(l, l + lim - 1, d);
        pSort(l + lim, r, d);
    }
}P;
int main()
{
    scanf("%d", &n);
    printf("%d\n",n);
    for(int i = 1; i <= n; i++)
        scanf("%d", p + i);
    for(int i = 1; i <= n; i++)
        if(p[i] != i)goto Z1;
    puts("0");
    return 0;
    Z1:
    for(int i = 1; i <= n; i++)
        if(p[i] != n - i + 1)goto ZR1;
    printf("1\n6");
    for(int i = 1; i <= n; i++)
        printf(" 1");
    return 0;
    ZR1:
    P.pSort(1, n, 1);
    for(int i = 1; i <= n; i++)
        if(p[i] != i)
            printf("Assertion failed: p[%d] = %d\n", i, p[i]);
    printf("120\n");
    for(int i = 1;i <= 120; i++)
    {
        std::vector<int>v;
        int cnt = 0;
        for(int z = 1; z <= n; z++)
        {
            if(z != 1)
                if(P.rec[i][z] == 0 || P.rec[i][z] != P.rec[i][z - 1])
                    v.push_back(cnt), cnt = 0;
            cnt++;
        }
        v.push_back(cnt);
        if(i % 2 == 0) std::reverse(v.begin(), v.end());
        printf("%d", v.size());
        for(int t : v)printf(" %d", t);
        puts("");
    }

}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3228kb

input:

4
3 1 2 4

output:

4
120
2 3 1
3 1 1 2
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
4 1 1 1 1
...

result:

wrong answer Integer 120 violates the range [2, 4]