QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#478681#905. 三元环枚举A_programmer#WA 13ms8344kbC++17947b2024-07-15 09:55:192024-07-15 09:55:20

Judging History

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

  • [2024-07-15 09:55:20]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:8344kb
  • [2024-07-15 09:55:19]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll mod = 998244353;
const int maxn = 1e5 + 5;

ll x[maxn];
int deg[maxn], U[maxn], V[maxn];
vector<int> g[maxn];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> x[i];
    for (int i = 1; i <= m; i++)
    {
        int u, v; cin >> u >> v;
        u++, v++; deg[u]++, deg[v]++;
        U[i] = u, V[i] = v;
    }
    for (int i = 1; i <= m; i++)
        if (deg[U[i]] < deg[V[i]] || (deg[U[i]] == deg[V[i]] && U[i] < V[i])) g[U[i]].emplace_back(V[i]);
        else g[V[i]].emplace_back(U[i]);
    
    ll ans = 0;
    for (int u = 1; u <= n; u++)
        for (int i = 0; i < g[u].size(); i++)
            for (int j = i + 1; j < g[u].size(); j++)
                (ans += x[u] * x[g[u][i]] % mod * x[g[u][j]]) %= mod;
    cout << ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 6296kb

input:

4 5
1 2 3 4
0 3
2 0
2 1
2 3
1 3

output:

36

result:

ok "36"

Test #2:

score: -100
Wrong Answer
time: 13ms
memory: 8344kb

input:

17707 77101
528756313 434883274 318065816 264440383 659789617 608119380 648104885 725454492 696703871 543030428 663661240 890791532 108201616 428505484 322953840 119811886 691103780 306647414 549862302 176916719 909058872 455464665 307270851 584469329 722629343 875317523 629938577 244419357 78121457...

output:

349295551

result:

wrong answer 1st words differ - expected: '397965084', found: '349295551'