QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#342700 | #905. 三元环枚举 | wcyQwQ# | WA | 6ms | 8748kb | C++17 | 1.2kb | 2024-03-01 15:09:02 | 2024-03-01 15:09:03 |
Judging History
answer
#include <bits/stdc++.h>
#define L(i, j, k) for (int i = (j); i <= (k); i++)
#define R(i, j, k) for (int i = (j); i >= (k); i--)
using namespace std;
using LL = long long;
using PII = pair<LL, int>;
const int N = 1e5 + 10, mod = 998244353;
vector<int> g[N];
int deg[N], a[N], vis[N];
pair<int, int> e[N];
template<class T = int> T read() {
T x = 0, y = 1;
char c = getchar();
while (c < '0' || c > '9') {
if (c == '-') {
y = -1;
}
c = getchar();
}
while (c >= '0' && c <= '9') {
x = x * 10 + c - '0';
c = getchar();
}
return x * y;
}
void inc(int &x, int y) {
if ((x += y) >= mod) {
x -= mod;
}
}
int main() {
int n = read(), m = read();
L(i, 1, n) {
a[i] = read();
}
L(i, 1, m) {
deg[e[i].first = read() + 1]++;
deg[e[i].second = read() + 1]++;
}
L(i, 1, m) {
int x = e[i].first, y = e[i].second;
if (deg[x] < deg[y] || (deg[x] == deg[y] && x < y)) {
g[x].emplace_back(y);
}
else {
g[y].emplace_back(x);
}
}
int res = 0;
L(u, 1, n) {
for (int v : g[u]) {
vis[v] = u;
}
for (int v : g[u]) {
for (int w : g[v]) {
if (vis[w] == u) {
inc(res, (LL)a[u] * a[v] * a[w] % mod);
}
}
}
}
printf("%d\n", res);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 6840kb
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: 6ms
memory: 8748kb
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:
-51422736
result:
wrong answer 1st words differ - expected: '397965084', found: '-51422736'