QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#239352#7688. Alea Iacta Estucup-team2307#WA 6ms4120kbC++171.9kb2023-11-04 20:15:262023-11-04 20:15:27

Judging History

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

  • [2023-11-04 20:15:27]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:4120kb
  • [2023-11-04 20:15:26]
  • 提交

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 = {(ll)1e18, -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) != para(1, n) && para(x, y) != para(1, m)) mn = min(mn, {x*y + n*m/x/y, x, y});
        x = n/i, y = j;
        if (para(x, y) != para(1, n) && para(x, y) != para(1, m)) mn = min(mn, {x*y + n*m/x/y, x, y});
        x = i, y = m/j;
        if (para(x, y) != para(1, n) && para(x, y) != para(1, m)) mn = min(mn, {x*y + n*m/x/y, x, y});
        x = n/i, y = m/j;
        if (para(x, y) != para(1, n) && para(x, y) != para(1, m)) mn = min(mn, {x*y + n*m/x/y, x, y});
    }

    if (mn[0] > n*m)
    {
        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: 1ms
memory: 3420kb

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: 3424kb

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: 3456kb

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: 3400kb

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: 3416kb

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: -100
Wrong Answer
time: 4ms
memory: 4120kb

input:

1
4 40013

output:

2 1 2
80026 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:

wrong answer Integer parameter [name=m1] equals to 80026, violates the range [1, 40021] (test case 1)