QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#66498#5154. ETAkaruna#WA 2ms3556kbC++171.4kb2022-12-08 19:57:342022-12-08 19:57:37

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-08 19:57:37]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3556kb
  • [2022-12-08 19:57:34]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

int sz = 1, lev[5050] = { 1, }, mx = 0, debug = 0;
vector<pair<int, int>> ans;
void make(int l) {
    assert(l <= mx + 1);
    mx = max(mx, l);
    debug += l;
    
    lev[l] = ++sz;
    ans.push_back({ lev[l - 1], lev[l] });
}
int main() {
    cin.tie(0); ios_base::sync_with_stdio(0);
    int a = 0, b = 0, t = 0; string S; cin >> S;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '/') ++t;
        else if (t == 0) {
            a = 10 * a + (S[i] & 15);
        }
        else {
            b = 10 * b + (S[i] & 15);
        }
    }
    if (a < b) {
        if (a != b - 1) {
            return !(cout << "impossible");
        }
        else {
            for (int i = 2; i <= b; i++) {
                make(1);
            }
            cout << sz << ' ' << ans.size() << '\n';
            for (auto [x, y] : ans) {
                cout << x << ' ' << y << '\n';
            }
        }
        return 0;
    }
    int n = (2001 + b - 1) / b * b;
    int x = n * a / b, s = 1;
    for (int i = 2; i <= n; i++) {
        if (x - s < n - i) {
            make(x - n + i + 1);
            for (int j = 0; j < n - i - 1; j++) make(1);
            break;
        }
        else {
            make(s);
            x -= s++;
        }
    }
    cout << sz << ' ' << ans.size() << '\n';
    for (auto [x, y] : ans) {
        cout << x << ' ' << y << '\n';
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3556kb

input:

1/2

output:

2 1
1 2

result:

ok 

Test #2:

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

input:

1/3

output:

impossible

result:

ok 

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 3524kb

input:

7/4

output:

2003 2002
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:

FAIL Wrong average distance, got 3507/2003, wanted 7/4