QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#480831#905. 三元环枚举win114514WA 27ms54036kbC++141.6kb2024-07-16 19:06:562024-07-16 19:06:56

Judging History

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

  • [2024-07-16 19:06:56]
  • 评测
  • 测评结果:WA
  • 用时:27ms
  • 内存:54036kb
  • [2024-07-16 19:06:56]
  • 提交

answer

/*
  ! 以渺小启程,以伟大结束。
  ! Created: 2024/07/16 18:54:48
*/
#include <bits/stdc++.h>
using namespace std;

#define x first
#define y second
// #define int long long
#define mp(x, y) make_pair(x, y)
#define eb(...) emplace_back(__VA_ARGS__)
#define fro(i, x, y) for (int i = (x); i <= (y); i++)
#define pre(i, x, y) for (int i = (x); i >= (y); i--)
inline void JYFILE19();

typedef long long i64;
typedef pair<int, int> PII;

bool ST;
const int N = 1e6 + 10;
const int mod = 998244353;

int n, m, ans, a[N], vs[N], ds[N], id[N];
vector<int> ot[N];
vector<int> to[N];

signed main() {
  JYFILE19();
  cin >> n >> m;
  fro(i, 1, n) cin >> a[i];
  fro(i, 1, m) {
    int x, y;
    cin >> x >> y;
    x++;
    y++;
    ot[x].eb(y);
    ot[y].eb(x);
  }
  iota(id + 1, id + n + 1, 1);
  sort(id + 1, id + n + 1, [&](int x, int y) {
    return ot[x].size() < ot[y].size();
  });
  pre(i, n, 1) {
    vs[i] = 1;
    for (auto j : ot[i]) if (vs[j]) to[i].eb(j);
  }
  fro(i, 1, n) {
    vs[i] = 0;
  }
  fro(i, 1, n) {
    int x = id[i];
    for (auto j : to[x]) if (!vs[j]) ds[j] = 1;
    for (auto j : to[x]) if (!vs[j]) for (auto k : to[j]) if (ds[k]) ans = (ans + 1ll * a[x] * a[j] % mod * a[k]) % mod;
    for (auto j : to[x]) if (!vs[j]) ds[j] = 0;
    vs[x] = 1;
  }
  cout << ans << "\n";
  return 0;
}

bool ED;
inline void JYFILE19() {
  // freopen("", "r", stdin);
  // freopen("", "w", stdout);
  srand(random_device{}());
  ios::sync_with_stdio(0), cin.tie(0);
  double MIB = fabs((&ED-&ST)/1048576.), LIM = 512;
  cerr << "MEMORY: " << MIB << endl, assert(MIB<=LIM);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 27ms
memory: 53580kb

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:

806837538

result:

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