QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#571697#9347. Competition in Swiss-systemreal_sigma_team#WA 0ms3640kbC++172.1kb2024-09-18 04:06:452024-09-18 04:06:45

Judging History

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

  • [2024-09-18 04:06:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3640kb
  • [2024-09-18 04:06:45]
  • 提交

answer

//#pragma GCC optimize("O3")
#include<bits/stdc++.h>

using namespace std;

typedef int ll;

void solve() {
	ll n, m;
	cin >> n >> m;
	vector<vector<ll>> all(n);
	vector<ll> mp(n, 0), gp(n, 0), cm(n, 0), cg(n, 0);
	vector<ll> cma(m);
	for (ll i = 0; i < m; i++) {
		cin >> cma[i];
	}
	for (ll i = 0; i < m; i++) {
		vector<bool> used(n, false);
		for (ll j = 0; j < cma[i]; j++) {
			ll a, b, w1, w2, d;
			cin >> a >> b >> w1 >> w2 >> d;
			a--;
			b--;
			used[a] = true;
			used[b] = true;
			if (w1 > w2) {
				mp[a] += 3;
			}
			if (w2 < w1) {
				mp[b] += 3;
			}
			if (w1 == w2) {
				mp[a]++;
				mp[b]++;
			}
			gp[a] += w1 * 3 + d;
			gp[b] += w2 * 3 + d;
			cg[a] += w1 + w2 + d;
			cg[b] += w1 + w2 + d;
			all[a].push_back(b);
			all[b].push_back(a);
		}
		for (ll j = 0; j < n; j++) {
			cm[j]++;
			if (!used[j]) {
				cg[j] += 2;
				gp[j] += 6;
				mp[j] += 3;
			}
		}
		cout << "Round " << i + 1 << '\n';
		for (ll j = 0; j < n; j++) {
			cout << mp[j] << ' ';
			ll col = 0, nu = 0, nd = 1;
			for (auto k : all[j]) {
				col++;
				ll nowu = mp[k], nowd = cm[k] * 3;
				if (nowu * 3 < nowd) {
					nowu = 1;
					nowd = 3;
				}
				ll x = nd * nowd / gcd(nd, nowd);
				nu *= x / nd;
				nd = x;
				nu += nowu * (x / nowd);
			}
			if (col == 0) {
				cout << "1/3" << ' ';
			} else {
				nd *= col;
				ll x = gcd(nu, nd);
				cout << nu / x << '/' << nd / x << ' ';
			}
			if (gp[j] * 3 < cg[j] * 3) {
				cout << "1/3" << ' ';
			} else {
				ll x = gcd(cg[j] * 3, gp[j]);
				cout << gp[j] / x << '/' << cg[j] * 3 / x << ' ';
			}
			col = 0;
			nu = 0;
			nd = 1;
			for (auto k : all[j]) {
				col++;
				ll nowu = gp[k], nowd = cg[k] * 3;
				if (nowu * 3 < nowd) {
					nowu = 1;
					nowd = 3;
				}
				ll x = nd * nowd / gcd(nd, nowd);
				nu *= x / nd;
				nd = x;
				nu += nowu * (x / nowd);
			}
			if (col == 0) {
				cout << "1/3" << ' ';
			} else {
				nd *= col;
				ll x = gcd(nu, nd);
				cout << nu / x << '/' << nd / x << ' ';
			}
			cout << '\n';
		}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t;
	cin >> t;
	while (t--) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3640kb

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/1 13/15 7/15 
6 1/1 7/15 13/15 
Round 3
7 7/9 17/24 11/24 
7 7/9 11/24 17/24 
Round 1
0 1/3 1/3 1/1 
0 1/3 1/1 1/3 
3 1/3 1/1 1/3 
Round 2
3 1/2 1/2 1/1 
3 3/4 1/1 1/2 
6 1/2 1/2 1/1 

result:

wrong answer 5th lines differ - expected: '6 1/2 13/15 7/15', found: '6 1/1 13/15 7/15 '