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 |
---|---|---|---|---|---|---|---|---|---|
#342024 | #905. 三元环枚举 | Ishy# | WA | 18ms | 7888kb | C++14 | 2.3kb | 2024-03-01 07:55:20 | 2024-03-01 07:55:21 |
Judging History
answer
// Sea, You & Me
#include<bits/stdc++.h>
#define LL long long
#define DB double
#define MOD 998244353
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
#define lowbit(x) ((-x) & x)
#define MP make_pair
#define MT make_tuple
#define VI vector<int>
#define VL vector<LL>
#define VII VI::iterator
#define VLI VL::iterator
#define all(x) x.begin(), x.end()
#define EB emplace_back
#define PII pair<int, int>
#define PLI pair<LL, int>
#define SI set<int>
#define SII SI::iterator
#define fi first
#define se second
using namespace std;
template<typename T> void chkmn(T &a, const T b) { (a > b) && (a = b); }
template<typename T> void chkmx(T &a, const T b) { (a < b) && (a = b); }
void Inc(int &a, const int &b) { ((a += b) >= MOD) && (a -= MOD); }
void Dec(int &a, const int &b) { ((a -= b) < 0) && (a += MOD); }
void Mul(int &a, const int &b) { a = 1LL * a * b % MOD; }
void Sqr(int &a) { a = 1LL * a * a % MOD; }
int inc(const int &a, const int &b) { return (a + b >= MOD) ? a + b - MOD : a + b; }
int dec(const int &a, const int &b) { return (a - b < 0) ? a - b + MOD : a - b; }
int mul(const int &a, const int &b) { return 1LL * a * b % MOD; }
int sqr(const int &a) { return 1LL * a * a % MOD; }
int qwqmi(int x, int k = MOD - 2)
{
int res = 1;
while(k)
{
if(k & 1) Mul(res, x);
k >>= 1, Sqr(x);
}
return res;
}
template<typename T> void read(T &x)
{
x = 0;
int f = 1;
char ch = getchar();
while(!isdigit(ch))
{
if(ch == '-')
f = -1;
ch = getchar();
}
while(isdigit(ch))
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
x = x * f;
}
const int N = 1e5 + 5;
const int M = 1e5 + 5;
int n, m, a[N];
vector<int> G[N];
int d[N];
bool cmp(int x, int y)
{
if(d[x] != d[y])
return d[x] > d[y];
return x > y;
}
int main()
{
read(n), read(m);
for(int i = 1; i <= n; ++i)
read(a[i]);
for(int i = 1; i <= m; ++i)
{
int u, v;
read(u), read(v);
++u, ++v;
++d[u], ++d[v];
G[u].EB(v), G[v].EB(u);
}
int ans = 0;
for(int u = 1; u <= n; ++u)
{
for(auto v : G[u])
{
if(!cmp(u, v)) continue;
for(auto w : G[v])
{
if(!cmp(u, w)) continue;
if(!cmp(v, w)) continue;
Inc(ans, mul(a[u], mul(a[v], a[w])));
}
}
}
printf("%d\n", ans);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 6184kb
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: 18ms
memory: 7888kb
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:
817964496
result:
wrong answer 1st words differ - expected: '397965084', found: '817964496'