QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#108648#5573. Holiday RegiftingLG_MonkeyWA 2ms3536kbC++141.1kb2023-05-25 21:51:422023-05-25 21:51:44

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-25 21:51:44]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3536kb
  • [2023-05-25 21:51:42]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define fi first
#define se second 
#define deb(var) cerr << #var << '=' << (var) << "; "
#define int long long
int n, m, c[10010];
const int mod = 998244353;
vector<int> g[10010]; int ind[10010], ord[10010], f[10010]; 
int lcm(int x, int y) {
	if (!x || !y) return x + y;
	return x / __gcd(x, y) * y;
}
signed main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> c[i];
	while (m--) {
		int u, v;
		cin >> u >> v; g[u].pb(v); ind[v]++;
	}
	int ans = c[1];
	f[1] = ans;
	for (int j = 1; j <= n; j++) {
		int u = j;
		for (int k = 0; k < g[u].size(); k++) {
			int v = g[u][k];
			f[v] += f[u] / c[u];
		}
		f[u] %= c[u];
	}
	for (int i = 2; i <= n; i++) {
		int u = i;
		int o = c[u] / __gcd(f[u], c[u]);
		for (int u = 1; u <= n; u++)
			f[u] *= o;
		for (int j = 1; j <= n; j++) {
			int u = j;
			for (int k = 0; k < g[u].size(); k++) {
				int v = g[u][k];
				f[v] += f[u] / c[u];
			}
			f[u] %= c[u];
		}
		ans = ans * o % mod;
	}
	for (int i = 1; i <= n; i++) cout << f[i] << " ";
	cout << ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 3536kb

input:

5 10
4 3 2 2 2
1 3
3 4
1 4
1 5
2 5
2 4
1 2
2 3
3 5
4 5

output:

0 0 0 0 0 24

result:

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