QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#597696#9347. Competition in Swiss-systemkjhhjkiCompile Error//C++203.3kb2024-09-28 18:28:152024-09-28 18:28:15

Judging History

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

  • [2024-09-28 18:28:15]
  • 评测
  • [2024-09-28 18:28:15]
  • 提交

answer

#include <bits//stdc++.h>

using i64 = long long;
using i128 = __int128;

std::ostream& operator<<(std::ostream &os, i128 x)
{
    std::string s;
    do {
        s.push_back(x % 10 + '0');
        x /= 10;
    }while(x);
    std::ranges::reverse(s);
    os << s;
    return os;
}

i128 gcd(i128 a, i128 b)
{
    if(b == 0) {
        return a;
    }
    return gcd(b, a % b);
}

struct fact
{
    i128 p, q;
    fact(i128 p = 0, i128 q = 1): p(p), q(q)
    {
        update();
        if(*this < fact(1, 3)) *this = fact(1, 3);
    }
    void update()
    {
        i128 g = gcd(p, q);
        p /= g; q /= g;
    }
    constexpr fact operator+(const fact &o) const { return fact(p * o.q + q * o.p, q * o.q); }
    constexpr fact operator-(const fact &o) const { return fact(p * o.q - q * o.p, q * o.q); }
    constexpr fact operator*(const fact &o) const { return fact(p * o.p, q * o.q); }
    constexpr fact operator/(const fact &o) const { return fact(p * o.q, q * o.p); }
    constexpr fact& operator+=(const fact &o) { return *this = *this + o; }
    constexpr fact& operator-=(const fact &o) { return *this = *this - o; }
    constexpr fact& operator*=(const fact &o) { return *this = *this * o; }
    constexpr fact& operator/=(const fact &o) { return *this = *this / o; }
    constexpr auto operator<=>(const fact &o) { return p * o.q <=> q * o.p; }
    friend std::ostream& operator<<(std::ostream &os, const fact &o)
    {
        return os << o.p << '/' << o.q;
    }
};

void solve()
{
    int n, m;
    std::cin >> n >> m;
    std::vector<int> a(m + 1);
    for(int i = 1; i <= m; ++i) {
        std::cin >> a[i];
    }
    std::vector<std::vector<int>> oppo(n + 1);
    std::vector<int> mp(n + 1), gp(n + 1), cnt(n + 1);
    std::vector<fact> omw(n + 1), gw = omw, ogw = gw;
    for(int i = 1; i <= m; ++i) {
        std::vector<bool> vis(n + 1);
        for(int j = 0; j < a[i]; ++j) {
            int p1, p2, w1, w2, d;
            std::cin >> p1 >> p2 >> w1 >> w2 >> d;
            vis[p1] = vis[p2] = true;
            gp[p1] += 3 * w1 + d;
            gp[p2] += 3 * w2 + d;
            if(w1 > w2) {
                mp[p1] += 3;
            } else if(w1 < w2) {
                mp[p2] += 3;
            } else {
                mp[p1] += 1;
                mp[p2] += 1;
            }
            oppo[p1].push_back(p2);
            oppo[p2].push_back(p1);
            cnt[p1] += 3 * (w1 + w2 + d);
            cnt[p2] += 3 * (w1 + w2 + d);
        }
        for(int i = 1; i <= n; ++i) {
            if(!vis[i]) {
                mp[i] += 3;
                gp[i] += 6;
                cnt[i] += 6;
            }
        }
        std::cout << "Round " << i << '\n';
        for(int j = 1; j <= n; ++j) {
            omw[j] = ogw[j] = 0;
            for(auto x: oppo[j]) {
                omw[j] += fact(mp[x], 3 * i);
                ogw[j] += fact(gp[x], cnt[x]);
            }
            if(oppo[j].size()) omw[j] /= oppo[j].size(), ogw[j] /= oppo[j].size();
            std::cout << mp[j] << ' ' << omw[j] << ' ' << fact(gp[j], cnt[j]) << ' ' << ogw[j] << '\n';
        }
    }
}

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

Details

answer.code: In constructor ‘fact::fact(i128, i128)’:
answer.code:32:29: warning: C++20 says that these are ambiguous, even though the second is reversed:
   32 |         if(*this < fact(1, 3)) *this = fact(1, 3);
      |                             ^
answer.code:47:20: note: candidate 1: ‘constexpr auto fact::operator<=>(const fact&)’ (rewritten)
   47 |     constexpr auto operator<=>(const fact &o) { return p * o.q <=> q * o.p; }
      |                    ^~~~~~~~
answer.code:47:20: note: candidate 2: ‘constexpr auto fact::operator<=>(const fact&)’ (reversed)
answer.code:47:20: note: try making the operator a ‘const’ member function
answer.code:32:29: error: use of ‘constexpr auto fact::operator<=>(const fact&)’ before deduction of ‘auto’
   32 |         if(*this < fact(1, 3)) *this = fact(1, 3);
      |                             ^
answer.code: In member function ‘constexpr fact fact::operator+(const fact&) const’:
answer.code:39:20: warning: invalid return type ‘fact’ of ‘constexpr’ function ‘constexpr fact fact::operator+(const fact&) const’ [-Winvalid-constexpr]
   39 |     constexpr fact operator+(const fact &o) const { return fact(p * o.q + q * o.p, q * o.q); }
      |                    ^~~~~~~~
answer.code:26:8: note: ‘fact’ is not literal because:
   26 | struct fact
      |        ^~~~
answer.code:26:8: note:   ‘fact’ is not an aggregate, does not have a trivial default constructor, and has no ‘constexpr’ constructor that is not a copy or move constructor
answer.code: In member function ‘constexpr fact fact::operator-(const fact&) const’:
answer.code:40:20: warning: invalid return type ‘fact’ of ‘constexpr’ function ‘constexpr fact fact::operator-(const fact&) const’ [-Winvalid-constexpr]
   40 |     constexpr fact operator-(const fact &o) const { return fact(p * o.q - q * o.p, q * o.q); }
      |                    ^~~~~~~~
answer.code: In member function ‘constexpr fact fact::operator*(const fact&) const’:
answer.code:41:20: warning: invalid return type ‘fact’ of ‘constexpr’ function ‘constexpr fact fact::operator*(const fact&) const’ [-Winvalid-constexpr]
   41 |     constexpr fact operator*(const fact &o) const { return fact(p * o.p, q * o.q); }
      |                    ^~~~~~~~
answer.code: In member function ‘constexpr fact fact::operator/(const fact&) const’:
answer.code:42:20: warning: invalid return type ‘fact’ of ‘constexpr’ function ‘constexpr fact fact::operator/(const fact&) const’ [-Winvalid-constexpr]
   42 |     constexpr fact operator/(const fact &o) const { return fact(p * o.q, q * o.p); }
      |                    ^~~~~~~~
answer.code: In member function ‘constexpr fact& fact::operator+=(const fact&)’:
answer.code:43:70: warning: temporary of non-literal type ‘fact’ in a constant expression [-Winvalid-constexpr]
   43 |     constexpr fact& operator+=(const fact &o) { return *this = *this + o; }
      |                                                                ~~~~~~^~~
answer.code: In member function ‘constexpr fact& fact::operator-=(const fact&)’:
answer.code:44:70: warning: temporary of non-literal type ‘fact’ in a constant expression [-Winvalid-constexpr]
   44 |     constexpr fact& operator-=(const fact &o) { return *this = *this - o; }
      |                                                                ~~~~~~^~~
answer.code: In member function ‘constexpr fact& fact::operator*=(const fact&)’:
answer.code:45:70: warning: temporary of non-literal type ‘fact’ in a constant expression [-Winvalid-constexpr]
   45 |     constexpr fact& operator*=(const fact &o) { return *this = *this * o; }
      |                                                                ~~~~~~^~~
answer.code: In member function ‘constexpr fact& fact::operator/=(const fact&)’:
answer.code:46:70: warning: temporary of non-literal type ‘fact’ in a constant expression [-Winvalid-constexpr]
   46 |     constexpr fact& operator/=(const fact &o) { return *this = *this / o; }
      |                                                                ~~~~~~^~~