QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#239492#7688. Alea Iacta Estucup-team2307#WA 95ms27756kbC++141.8kb2023-11-04 20:57:212023-11-04 20:57:22

Judging History

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

  • [2023-11-04 20:57:22]
  • 评测
  • 测评结果:WA
  • 用时:95ms
  • 内存:27756kb
  • [2023-11-04 20:57:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define fi first
#define se second

typedef long long ll;
#define int ll

pair<int, int> para(int x, int y)
{
    if (x > y) swap(x, y);
    return {x, y};
}

void solve()
{
    int n, m;
    cin>>n>>m;

    array<int, 3> mn = {2*min(n, m) + max(n, m), -1, -1};
    for (int i=1; i*i<=n; i++)
        if (n%i == 0)
        for (int j=1; j*j<=m; j++)
            if (m%j == 0)
    {
        int x, y;
        x = i, y = j;
        if (para(x*y, n*m/x/y) != para(n, m)) mn = min(mn, {x*y + n*m/x/y, x, y});
        x = n/i, y = j;
        if (para(x*y, n*m/x/y) != para(n, m)) mn = min(mn, {x*y + n*m/x/y, x, y});
        x = i, y = m/j;
        if (para(x*y, n*m/x/y) != para(n, m))  mn = min(mn, {x*y + n*m/x/y, x, y});
        x = n/i, y = m/j;
        if (para(x*y, n*m/x/y) != para(n, m))  mn = min(mn, {x*y + n*m/x/y, x, y});
    }

    if (mn[1] < 0)
    {
        if (n > m)
            swap(n, m);
        cout<<2*n;
        for (int i=1; i<=n; i++)
            cout<<" "<<i<<" "<<i;
        cout<<"\n";
        cout<<m;
        for (int i=1; i<=m; i++)
            cout<<" "<<i;
        cout<<"\n";
        cout<<"\n";
        return;
    }

    vector<int> g1, g2;
    int x = mn[1];
    int y = mn[2];
    for (int i=1; i<=x; i++)
        for (int j=1; j<=y; j++)
            g1.pb(i+j-1);
    for (int i=1; i<=n; i+=x)
        for (int j=1; j<=m; j+=y)
            g2.pb(i+j-1);
//    cout<<x<<" "<<y<<"\n";
    cout<<g1.size();
    for (int i : g1) cout<<" "<<i;
    cout<<"\n";
    cout<<g2.size();
    for (int i : g2) cout<<" "<<i;
    cout<<"\n";
    cout<<"\n";
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    cin>>n;
    while (n--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3824kb

input:

3
2 8
1 9
2 9

output:

4 1 2 3 4
4 1 5 2 6

3 1 2 3
3 1 4 7

3 1 2 3
6 1 4 7 2 5 8


result:

ok Correct. (3 test cases)

Test #2:

score: 0
Accepted
time: 6ms
memory: 3596kb

input:

1
40013 40013

output:

80026 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 52 ...

result:

ok Correct. (1 test case)

Test #3:

score: 0
Accepted
time: 2ms
memory: 3748kb

input:

1
40013 1

output:

2 1 1
40013 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 ...

result:

ok Correct. (1 test case)

Test #4:

score: 0
Accepted
time: 2ms
memory: 3824kb

input:

1
2 40013

output:

4 1 1 2 2
40013 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...

result:

ok Correct. (1 test case)

Test #5:

score: 0
Accepted
time: 2ms
memory: 3596kb

input:

1
3 40013

output:

6 1 1 2 2 3 3
40013 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 9...

result:

ok Correct. (1 test case)

Test #6:

score: 0
Accepted
time: 2ms
memory: 3612kb

input:

1
4 40013

output:

8 1 1 2 2 3 3 4 4
40013 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 ...

result:

ok Correct. (1 test case)

Test #7:

score: 0
Accepted
time: 95ms
memory: 3528kb

input:

1
999983 999983

output:

1999966 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52 5...

result:

ok Correct. (1 test case)

Test #8:

score: 0
Accepted
time: 46ms
memory: 3528kb

input:

1
1 999983

output:

2 1 1
999983 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99...

result:

ok Correct. (1 test case)

Test #9:

score: 0
Accepted
time: 41ms
memory: 3752kb

input:

1
2 999983

output:

4 1 1 2 2
999983 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 9...

result:

ok Correct. (1 test case)

Test #10:

score: 0
Accepted
time: 41ms
memory: 3620kb

input:

1
999983 3

output:

6 1 1 2 2 3 3
999983 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 ...

result:

ok Correct. (1 test case)

Test #11:

score: 0
Accepted
time: 42ms
memory: 3616kb

input:

1
999983 4

output:

8 1 1 2 2 3 3 4 4
999983 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95...

result:

ok Correct. (1 test case)

Test #12:

score: -100
Wrong Answer
time: 77ms
memory: 27756kb

input:

1
1000000 1000000

output:

800000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 1...

result:

wrong answer Jury has a better answer. (test case 1)