QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#352969 | #7860. Graph of Maximum Degree 3 | ucup-team3215# | WA | 1ms | 3636kb | C++20 | 773b | 2024-03-13 19:10:01 | 2024-03-13 19:10:01 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
constexpr int N = 1e5;
vector<int> nei[2][N];
bool con(int t, int v, int u) { return !!count(nei[t][v].begin(), nei[t][v].end(), u); }
int main() {
cin.tie(0)->sync_with_stdio(0);
int n, m; cin >> n >> m;
for (int i = 0; i < m; ++i) {
int a, b, c; cin >> a >> b >> c; --a, --b;
nei[c][a].push_back(b);
nei[c][b].push_back(a);
}
uint64_t ans[5]{};
for (int i = 0; i < n; ++i)
for (auto v: nei[0][i])
for (auto u: nei[1][i]) if (ans[2] += v == u, ans[3] += con(0, v, u) && con(1, v, u), (con(0, v, u) || con(0, i, u)) && i < v)
for (auto w: nei[0][con(0, i, u)? v: i]) ans[4] += con(1, v, w) && con(1, u, w);
cout << (n + ans[2] / 2 + ans[3] + ans[4]) % 998244353;
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3636kb
input:
3 4 1 2 0 1 3 1 2 3 0 2 3 1
output:
6
result:
wrong answer 1st numbers differ - expected: '5', found: '6'