QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#291258#7860. Graph of Maximum Degree 3ucup-team2279WA 2ms8344kbC++14856b2023-12-26 09:28:332023-12-26 09:28:33

Judging History

你现在查看的是最新测评结果

  • [2023-12-26 09:28:33]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8344kb
  • [2023-12-26 09:28:33]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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'