QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#543436#5043. GameAndyqian7WA 179ms3768kbC++141.7kb2024-09-01 16:49:462024-09-01 16:49:50

Judging History

你现在查看的是最新测评结果

  • [2024-09-01 16:49:50]
  • 评测
  • 测评结果:WA
  • 用时:179ms
  • 内存:3768kb
  • [2024-09-01 16:49:46]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
bool fight(int *a, int *b)
{
    int p = 0, q = 0;
    while (p < 24 && q < 24)
    {
        int A = a[p], B = b[q];
        if (A == B || A == 30 || B == 30)
            p++, q++;
        else if (A == 31 && B == 32)
            p++;
        else if (A == 32 && B == 31)
            q++;
        else if (A == 31 && B > 32)
            q++;
        else if (A > 32 && B == 31)
            p++;
        else if (A > B)
            q++;
        else if (B > A)
            p++;
    }
    return q < 24;
}
int check(int *aa, int *bb)
{
    int ret = 0;
    for (int i = 0; i < 24; i++)
    {
        for (int j = 0; j < i; j++)
        {
            swap(bb[i], bb[j]);
            ret += fight(aa, bb) > 0;
            swap(bb[i], bb[j]);
        }
    }
    return ret;
}
int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        int a[24], b[24];
        for (int i = 0; i < 24; i++)
        {
            cin >> a[i];
            b[i] = a[i];
        }
        mt19937 mt(time(0));
        shuffle(b, b + 24, mt);
        int cur = check(a, b);
        for (int l = 0; l < 500; l++)
        {
            int i = rand() % 24, j = rand() % 24;
            swap(b[i], b[j]);
            int tmp = check(a, b);
            if (tmp > cur)
            {
                cur = tmp;
            }
            else
            {
                swap(b[i], b[j]);
            }
            if (cur == 276)
                break;
        }
        if (cur == 276)
            for (int i = 0; i < 24; i++)
            {
                cout << b[i] << " ";
            }
        else
            cout << "-1";
        cout << endl;
    }
}

详细

Test #1:

score: 100
Accepted
time: 6ms
memory: 3648kb

input:

4
40 39 38 38 37 37 36 36 35 35 34 34 34 33 33 33 32 32 32 31 31 31 30 30
34 31 36 33 31 39 37 38 35 32 32 35 36 31 34 32 38 40 30 33 30 34 33 37
37 30 40 38 36 38 32 34 36 35 37 32 34 33 31 30 33 31 35 34 33 39 31 32
30 33 32 39 37 38 35 40 34 30 31 37 31 33 31 33 34 32 36 36 35 34 32 38

output:

35 39 34 31 38 35 32 38 36 34 30 40 33 36 31 34 33 32 31 33 37 32 30 37 
34 34 32 33 36 33 39 32 37 32 37 40 30 38 31 35 31 38 30 35 33 36 34 31 
35 30 33 34 31 36 31 38 32 37 32 37 33 34 32 34 31 40 39 30 38 35 33 36 
33 40 34 31 32 34 36 39 35 31 38 30 33 33 35 31 36 37 34 32 38 30 32 37 

result:

ok AC

Test #2:

score: 0
Accepted
time: 1ms
memory: 3768kb

input:

1
31 37 34 39 36 34 38 36 31 40 30 34 37 35 33 33 38 33 31 32 30 32 32 35

output:

40 37 34 32 34 31 33 32 31 30 35 38 35 36 30 37 33 38 32 33 34 31 39 36 

result:

ok AC

Test #3:

score: 0
Accepted
time: 5ms
memory: 3764kb

input:

2
36 39 34 31 36 32 33 30 31 34 38 35 33 34 37 38 32 31 40 32 30 37 33 35
38 34 34 32 40 32 37 36 30 33 36 32 31 33 39 33 35 34 31 38 31 37 35 30

output:

34 31 38 32 37 31 37 35 31 38 32 39 33 30 33 34 34 32 36 35 30 36 33 40 
33 39 40 34 35 30 38 32 37 36 33 32 30 36 31 31 32 37 35 33 31 38 34 34 

result:

ok AC

Test #4:

score: -100
Wrong Answer
time: 179ms
memory: 3696kb

input:

100
33 30 34 34 32 31 39 33 36 35 38 31 37 37 33 36 35 31 32 38 40 30 32 34
35 38 33 30 40 30 35 39 31 38 37 33 37 31 34 34 32 36 33 32 36 32 34 31
31 30 36 31 40 33 33 30 38 32 34 38 39 34 37 35 33 36 35 34 32 32 37 31
30 40 36 35 37 36 33 31 35 34 33 34 31 33 30 32 38 39 32 37 38 34 32 31
34 34 31...

output:

35 39 36 38 34 32 31 40 30 38 34 33 30 33 31 36 33 32 37 35 31 37 34 32 
38 38 30 32 33 31 36 30 35 37 31 35 31 39 33 37 34 32 32 34 36 33 34 40 
32 36 33 32 35 38 36 33 30 34 34 31 39 31 34 37 40 33 32 35 38 30 37 31 
34 34 34 31 36 31 39 35 33 33 31 30 33 35 38 37 30 38 40 32 36 32 32 37 
39 34 30...

result:

wrong answer Integer -1 violates the range [30, 40]