QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#343126 | #905. 三元环枚举 | Terac# | WA | 4ms | 11644kb | C++14 | 2.1kb | 2024-03-01 22:47:47 | 2024-03-01 22:47:48 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
namespace IO {
#if ONLINE_JUDGE
#define getc() (IS == IT && (IT = (IS = ibuf) + fread(ibuf, 1, IL, stdin), IS == IT) ? EOF : *IS++)
#else
#define getc() getchar()
#endif
const int IL = 1 << 21, OL = 1 << 21;
int olen = 0;
char ibuf[IL], *IS = ibuf, *IT = ibuf, obuf[OL];
inline int read() {
register char ch = getc(); register int x = 0, f = 1;
while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getc(); }
while(isdigit(ch)) x = x * 10 + ch - 48, ch = getc();
return x * f;
}
inline double readdb() {
register char ch = getc(); register double x = 0, f = 1;
while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getc(); }
while(isdigit(ch)) x = x * 10 + ch - 48, ch = getc();
if(ch == '.') {
register double b = 0.1;
ch = getc();
while(isdigit(ch)) x += (ch - 48) * b, b *= 0.1, ch = getc();
}
return x * f;
}
inline int readstr(char *s) {
register char ch = getc(); register int len = 0;
while(!isalpha(ch)) ch = getc();
while(isalpha(ch)) s[++len] = ch, ch = getc();
return len;
}
inline void flush() { fwrite(obuf, 1, olen, stdout); olen = 0; }
inline void putc(register char ch) { obuf[olen++] = ch; }
template<class T>
inline void write(register T x) {
if(x < 0) obuf[olen++] = '-', x = -x;
if(x > 9) write(x / 10);
obuf[olen++] = x % 10 + 48;
}
} using namespace IO;
const int N = 1e5 + 10;
int n, m, a[N];
int u[N], v[N], du[N];
bool vis[N];
vector<int> e[N];
int main() {
n = read(), m = read();
for(int i = 1; i <= n; i++)
a[i] = read();
for(int i = 1; i <= m; i++) {
u[i] = read() + 1, v[i] = read() + 1;
du[u[i]]++, du[v[i]]++;
}
for(int i = 1; i <= m; i++)
if(make_pair(du[u[i]], u[i]) < make_pair(du[v[i]], v[i]))
e[u[i]].push_back(v[i]);
else e[v[i]].push_back(u[i]);
long long ans = 0;
for(int i = 1; i <= n; i++) {
for(auto v : e[i])
vis[v] = 1;
for(auto v : e[i]) {
for(auto w : e[v])
if(i != v && v != w && i != w && vis[w])
ans += 1ll * a[i] * a[v] * a[w];
}
for(auto v : e[i])
vis[v] = 0;
}
cout << ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 11564kb
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: 4ms
memory: 11644kb
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:
-4805848128182623126
result:
wrong answer 1st words differ - expected: '397965084', found: '-4805848128182623126'