QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#108648 | #5573. Holiday Regifting | LG_Monkey | WA | 2ms | 3536kb | C++14 | 1.1kb | 2023-05-25 21:51:42 | 2023-05-25 21:51:44 |
Judging History
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'