QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#291258 | #7860. Graph of Maximum Degree 3 | ucup-team2279 | WA | 2ms | 8344kb | C++14 | 856b | 2023-12-26 09:28:33 | 2023-12-26 09:28:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5,mod=998244353;
int n,m;
long long ans;
vector<int> r[N],b[N];
set<array<int,2>> s;
map<array<int,4>,int> mp;
void add(int x,int y,auto&e) {e[x].push_back(y);e[y].push_back(x);}
int main(){
cin.tie(0)->sync_with_stdio(0);
cin>>n>>m;
for(int u,v,c;m--;) cin>>u>>v>>c,add(u,v,c?r:b);
ans=n;
for(int x=1;x<=n;x++) for(int y:r[x]) if(x<y&&count(begin(b[x]),end(b[x]),y)) s.insert({x,y}),ans++;
for(int x=1;x<=n;x++) for(int u:r[x]) for(int v:b[x]) if(s.count({u,v})||s.count({v,u})) ans++;
for(int x=1;x<=n;x++) for(int y:r[x]) for(int z:r[y]) if(z!=x) for(int w:r[z]) if(w<x&&w!=y) mp[{min(y,z),max(y,z),x,w}]++;
for(int x=1;x<=n;x++) for(int y:b[x]) for(int z:b[y]) if(z!=x) for(int w:b[z]) if(w<x&&w!=y) ans+=mp[{w,x,min(y,z),max(y,z)}];
cout<<ans%mod;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 8344kb
input:
3 4 1 2 0 1 3 1 2 3 0 2 3 1
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 8312kb
input:
4 6 1 2 0 2 3 0 3 4 0 1 4 1 2 4 1 1 3 1
output:
4
result:
wrong answer 1st numbers differ - expected: '5', found: '4'