QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501530#5154. ETAUmokWA 0ms3816kbC++201.1kb2024-08-02 20:09:172024-08-02 20:09:19

Judging History

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

  • [2024-08-02 20:09:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3816kb
  • [2024-08-02 20:09:17]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 1e6 + 5;
#define int long long
typedef pair<int, int> PII;
#define MAX LONG_LONG_MAX
int ar[N], f[N];
void solve()
{
    int a, b;
    scanf("%lld/%lld", &a, &b);
    int num = 1;

    while (1)
    {
        int x = (1 + num * (b - 1)) * num * (b - 1) / 2;
        if (x < num * a)
            num++;
        else
            break;
    }
    a = a * num, b = b * num;
    if (b - 1 > a)
    {
        cout << "impossible" << endl;
        return;
    }
    num = (1 + (b - 1)) * (b - 1) / 2 - a;
    for (int i = 2; i <= b; i++)
        f[i] = i - 1;
    for (int i = b; i > 1; i--)
    {
        int x = i - 1;
        if (num >= x)
        {
            f[i] = 1;
            num -= x;
        }
        else if (num)
        {
            f[i] = num + 1;
            break;
        }
        if (num <= 0)
            break;
    }
    cout << b << " " << b - 1 << endl;
    for (int i = 2; i <= b; i++)
    {
        cout << f[i] << " " << i << endl;
    }
}
signed main()
{

    solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1/2

output:

2 1
1 2

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

1/3

output:

impossible

result:

ok 

Test #3:

score: 0
Accepted
time: 0ms
memory: 3692kb

input:

7/4

output:

8 7
1 2
2 3
3 4
4 5
2 6
1 7
1 8

result:

ok 

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3760kb

input:

974/975

output:

975 974
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
17 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
...

result:

FAIL Wrong average distance, got 1893/975, wanted 974/975