QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#304832#8008. Fortune Wheelucup-team2000#WA 38ms5188kbC++202.2kb2024-01-14 03:57:072024-01-14 03:57:08

Judging History

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

  • [2024-07-30 15:38:33]
  • hack成功,自动添加数据
  • (/hack/759)
  • [2024-07-10 08:02:33]
  • hack成功,自动添加数据
  • (/hack/730)
  • [2024-01-14 03:57:08]
  • 评测
  • 测评结果:WA
  • 用时:38ms
  • 内存:5188kb
  • [2024-01-14 03:57:07]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define lep(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,b,a) for(int i = (b); i >= (a); i--)
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
const int inf = 1e18;

// const int mod = 1e9 + 7;
int reduce(int x, int n) {
    return (x %= n) < 0 ? x + n : x;
}

// int prod(int a, int b) {
//     return reduce(reduce(a) * reduce(b));
// }

// int add(int a, int b) {
//     return reduce(reduce(a) + reduce(b));
// }

// int modpow(int a, int pw) {
//     if (a == 0) return 0;
//     if (pw == 0) return 1;
//     if (pw % 2 == 0) {
//         int res = modpow(a, pw / 2);
//         return prod(res, res);
//     }
//     return prod(modpow(a,pw), a);
// }

pi red(pi p) {
    int g = __gcd(p.f,p.s);
    return {p.f/g,p.s/g};
}

pi get_better(pi a, pi b) {
    a = red(a);
    b = red(b);
    // a.f / a.s < b.f / b.s whenever a.f * b.s < a.s * b.f
    if (a.f == inf) return b;
    if (a.f * b.s < a.s * b.f) return a;
    return b;
}

void submit(int ans) {
    cout << ans << "\n";
}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, x,k;
    cin >> n >> x >> k;
    vector<int> F(n, inf);
    vector<bool> visited(n);
    visited[0] = true;
    F[0] = 0;

    vector<int> vals(k+1);
    lep(i,1,k) {
        cin >> vals[i];
    }
    queue<int> q;
    F[0] = 0;
    visited[0] = 0;
    q.push(0);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        lep(i,1,k) {
            int len = vals[i];
            int v = reduce(u - len, n);
            if (!visited[v]) {
                visited[v] = 1;
                F[v] = F[u] + 1;
                q.push(v);
            }
        }
    }
    vector<int> dists(n+1);
    lep(i,1,n) dists[i] = F[i];
    sort(dists.begin()+1,dists.end());
    pi ans = {F[x],1};
    int sm = 0;
    lep(i,1,n-1) {
        sm += dists[i];
        if (dists[i] < F[x] and dists[i] != dists[i+1]) {
            // c = 1 + 1/n sum_{i=1}^i dists[i] + (n-i)/n * c
            ans = get_better(ans, mp(n+sm,i));
        }
    }
    cout << ans.f << " " << ans.s << "\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6 3 2
2 4

output:

8 3

result:

ok 2 number(s): "8 3"

Test #2:

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

input:

5 4 1
1

output:

1 1

result:

ok 2 number(s): "1 1"

Test #3:

score: 0
Accepted
time: 38ms
memory: 5188kb

input:

99999 65238 100
64714 45675 36156 13116 93455 22785 10977 60219 14981 25839 83709 80404 41400 12469 31530 65521 35436 20326 96792 50699 27522 98233 26187 12509 90992 72693 83919 74145 80892 68422 38333 33497 89154 88403 77492 4570 3908 59194 3482 89871 96330 45114 5555 73987 95832 476 949 74649 2084...

output:

3 1

result:

ok 2 number(s): "3 1"

Test #4:

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

input:

10000 23 7
9594 8998 9330 6851 1662 6719 583

output:

42726 4805

result:

ok 2 number(s): "42726 4805"

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 3544kb

input:

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

output:

2 1

result:

wrong answer 1st numbers differ - expected: '1', found: '2'