QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#597726 | #9347. Competition in Swiss-system | kjhhjki | WA | 0ms | 3564kb | C++20 | 3.2kb | 2024-09-28 18:33:12 | 2024-09-28 18:33:12 |
Judging History
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;
auto operator<=>(const fact &o) const { return p * o.q <=> q * o.p; }
fact(i128 p = 0, i128 q = 1): p(p), q(q)
{
update();
if(p * 3 < q) *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; }
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);
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) {
fact omw = 0, ogw = 0;
for(auto x: oppo[j]) {
omw += fact(mp[x], 3 * i);
ogw += fact(gp[x], cnt[x]);
}
if(oppo[j].size()) omw /= oppo[j].size(), ogw /= oppo[j].size();
std::cout << mp[j] << ' ' << omw << ' ' << fact(gp[j], cnt[j]) << ' ' << ogw << '\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
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3564kb
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 5/6 13/15 4/5 3 4/3 7/15 6/5 Round 3 7 11/18 17/24 5/8 4 17/18 11/24 7/8 Round 1 0 4/3 1/3 4/3 3 2/3 1/1 2/3 3 1/3 1/1 1/3 Round 2 3 4/3 1/2 4/3 6 2/3 1/1 2/3 3 4/3 1/2 4/3
result:
wrong answer 5th lines differ - expected: '6 1/2 13/15 7/15', found: '6 5/6 13/15 4/5'