QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#571467#9347. Competition in Swiss-systemucup-team004#WA 162ms3820kbC++203.2kb2024-09-17 23:18:592024-09-17 23:19:00

Judging History

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

  • [2024-09-17 23:19:00]
  • 评测
  • 测评结果:WA
  • 用时:162ms
  • 内存:3820kb
  • [2024-09-17 23:18:59]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;

using i128 = __int128;

i128 gcd(i128 a, i128 b) {
    while (b) {
        a %= b;
        std::swap(a, b);
    }
    return a;
}

std::ostream &operator<<(std::ostream &os, i128 n) {
    constexpr i64 M = 1E18;
    if (n >= M) {
        return os << i64(n / M) << std::setw(18) << std::setfill('0') << i64(n % M);
    } else {
        return os << i64(n);
    }
}

constexpr i128 M = i128(47) * 43 * 41 * 37 * 32 * 31 * 29 * 27 * 25 * 23 * 19 * 17 * 13 * 11 * 3;

void solve() {
    int n, m;
    std::cin >> n >> m;
    
    std::vector<int> mc(1 + m);
    for (int i = 1; i <= m; i++) {
        std::cin >> mc[i];
    }
    
    std::vector<int> mp(n), gp(n), gc(n);
    std::vector<std::vector<int>> op(n);
    for (int r = 1; r <= m; r++) {
        std::vector<bool> vis(n);
        for (int i = 0; i < mc[r]; i++) {
            int a, b, w, l, d;
            std::cin >> a >> b >> w >> l >> d;
            a--;
            b--;
            vis[a] = true;
            vis[b] = true;
            op[a].push_back(b);
            op[b].push_back(a);
            gc[a] += w + l + d;
            gc[b] += w + l + d;
            gp[a] += w * 3 + d;
            gp[b] += l * 3 + d;
            if (w > l) {
                mp[a] += 3;
            } else if (w < l) {
                mp[b] += 3;
            } else {
                mp[a] += 1;
                mp[b] += 1;
            }
        }
        for (int x = 0; x < n; x++) {
            if (!vis[x]) {
                mp[x] += 3;
                gp[x] += 6;
                gc[x] += 2;
            }
        }
        std::cout << "Round " << r << "\n";
        for (int i = 0; i < n; i++) {
            std::cout << mp[i] << " ";
            
            int p, q;
            if (op[i].empty()) {
                p = 1;
                q = 3;
            } else {
                p = 0;
                q = 3 * r * op[i].size();
                for (auto x : op[i]) {
                    p += std::max(r, mp[x]);
                }
            }
            int g = std::gcd(p, q);
            p /= g;
            q /= g;
            std::cout << p << "/" << q << " ";
            
            p = std::max(gc[i], gp[i]);
            q = 3 * gc[i];
            g = std::gcd(p, q);
            p /= g;
            q /= g;
            std::cout << p << "/" << q << " ";
            
            {
                i128 p, q;
                if (op[i].empty()) {
                    p = 1;
                    q = 3;
                } else {
                    p = 0;
                    q = 3 * M * op[i].size();
                    for (auto x : op[i]) {
                        p += std::max(gc[x], gp[x]) * (M / gc[x]);
                    }
                }
                i128 g = gcd(p, q);
                p /= g;
                q /= g;
                std::cout << p << "/" << q << "\n";
            }
        }
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int T;
    std::cin >> T;
    
    while (T--) {
        solve();
    }
    
    return 0;
}

詳細信息

Test #1:

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

input:

2
2 3
0 1 1
1 2 2 0 1
1 2 1 1 1
3 2
1 1
1 2 0 2 0
2 3 2 0 0

output:

Round 1
3 1/3 1/1 1/3
3 1/3 1/1 1/3
Round 2
6 1/2 13/15 7/15
3 1/1 7/15 13/15
Round 3
7 4/9 17/24 11/24
4 7/9 11/24 17/24
Round 1
0 1/1 1/3 1/1
3 1/3 1/1 1/3
3 1/3 1/1 1/3
Round 2
3 1/1 1/2 1/1
6 1/2 1/1 1/2
3 1/1 1/2 1/1

result:

ok 17 lines

Test #2:

score: -100
Wrong Answer
time: 162ms
memory: 3648kb

input:

3215
26 4
13 13 11 13
19 9 2 1 0
17 1 0 2 0
25 15 2 0 0
14 5 1 2 0
20 2 0 2 0
10 21 2 1 0
3 16 0 2 0
8 6 2 1 0
26 24 1 2 0
22 18 0 1 2
7 11 2 0 0
13 4 1 2 0
23 12 0 2 0
18 20 1 2 0
3 5 2 1 0
25 24 1 2 0
7 9 1 2 0
11 14 2 0 0
8 17 1 1 1
23 12 2 0 0
19 26 1 2 0
2 15 0 2 0
4 13 2 1 0
16 10 0 2 0
6 21 0...

output:

Round 1
3 1/3 1/1 1/3
3 1/3 1/1 1/3
0 1/1 1/3 1/1
3 1/3 2/3 1/3
3 1/3 2/3 1/3
0 1/1 1/3 2/3
3 1/3 1/1 1/3
3 1/3 2/3 1/3
0 1/1 1/3 2/3
3 1/3 2/3 1/3
0 1/1 1/3 1/1
3 1/3 1/1 1/3
0 1/1 1/3 2/3
0 1/1 1/3 2/3
0 1/1 1/3 1/1
3 1/3 1/1 1/3
0 1/1 1/3 1/1
3 1/3 5/9 1/3
3 1/3 2/3 1/3
0 1/1 1/3 1/1
0 1/1 1/3 2/...

result:

wrong answer 56th lines differ - expected: '6 7/18 2/3 3/7', found: '6 7/18 2/3 13552672759093280057/31622903104550986800'