QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#241054 | #6354. 4 | jzh | WA | 1ms | 6340kb | C++20 | 1.1kb | 2023-11-05 22:29:41 | 2023-11-05 22:29:42 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int deg[N];
vector<int> G[N];
typedef pair<int, int> pii;
bitset<400> to[N];
int id[N];
int main() {
ios::sync_with_stdio(false);
int n, m;
cin >> n >> m;
vector<pii> e;
for (int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
e.push_back({u, v});
deg[u]++, deg[v]++;
}
for (auto [u, v]: e) {
if (deg[u] > deg[v] || (deg[u] == deg[v] && u > v)) swap(u, v);
G[u].push_back(v);
}
long long ans = 0;
for (int i = 1; i <= n; i++) {
int cnt = 1;
for (int v: G[i]) {
id[v] = (cnt++);
to[v].reset();
}
for (int v: G[i]) {
for (int p: G[v]) {
if (id[p]) {
to[v][id[p]] = 1;
}
}
}
for (int v: G[i]) {
for (int p: G[v]) {
ans += (to[v] & to[p]).count();
}
}
}
cout << ans ;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6212kb
input:
5 9 1 2 1 3 1 4 1 5 2 3 2 4 2 5 3 4 3 5
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 1ms
memory: 6096kb
input:
4 0
output:
0
result:
ok 1 number(s): "0"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 6340kb
input:
50 50 28 35 12 24 31 50 10 24 21 44 5 31 23 36 31 45 6 39 4 8 13 37 42 48 17 45 19 33 12 21 19 32 16 43 12 47 25 31 40 48 8 49 43 48 6 42 27 34 13 39 17 40 13 35 3 49 20 24 5 12 43 44 15 37 24 27 8 43 4 22 17 38 28 47 29 46 3 15 9 49 1 41 43 45 3 6 37 48 13 30 11 43 8 25 33 38 16 32 32 41
output:
3
result:
wrong answer 1st numbers differ - expected: '0', found: '3'