QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#543419#5043. GameAndyqian7WA 278ms3704kbC++141.8kb2024-09-01 16:45:532024-09-01 16:45:55

Judging History

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

  • [2024-09-01 16:45:55]
  • 评测
  • 测评结果:WA
  • 用时:278ms
  • 内存:3704kb
  • [2024-09-01 16:45:53]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int 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]);
            if (fight(aa, bb) > 0)
                ret++;
            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 i = 23; i; i--)
        {
            for (int j = 0; j < 24 - i; j++)
            {
                swap(b[i + j], b[j]);
                int tmp = check(a, b);
                if (tmp > cur)
                {
                    cur = tmp;
                }
                else
                {
                    swap(b[i + j], b[j]);
                }
            }
            if (cur == 276)
                break;
        }
        if (cur == 276)
            for (int i = 0; i < 24; i++)
            {
                cout << b[i] << " ";
            }
        else
            cout << "-1";
        cout << endl;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
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 38 30 34 40 33 32 33 31 33 39 38 32 31 37 34 37 35 31 32 34 36 36 30 
35 34 32 36 34 32 38 34 31 37 31 36 30 32 39 35 30 33 33 40 33 38 37 31 
38 38 31 37 37 34 36 30 32 33 30 40 35 39 34 32 36 35 34 33 31 31 32 33 
34 38 35 31 30 33 32 31 35 33 33 32 36 34 38 37 37 30 36 34 31 40 32 39 

result:

ok AC

Test #2:

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

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:

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

result:

ok AC

Test #3:

score: 0
Accepted
time: 11ms
memory: 3676kb

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:

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

result:

ok AC

Test #4:

score: -100
Wrong Answer
time: 278ms
memory: 3704kb

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:

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

result:

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