QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#476817#905. 三元环枚举templatetemplate#WA 14ms10348kbC++171.3kb2024-07-13 21:04:062024-07-13 21:04:06

Judging History

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

  • [2024-07-13 21:04:06]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:10348kb
  • [2024-07-13 21:04:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
	x=0;
	bool flag=0;
	char ch=getchar();
	while(ch<'0'||ch>'9') flag=flag||(ch=='-'),ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	x=flag?-x:x;
}
template<typename T,typename ...Args>inline void read(T &x,Args &...args){
	read(x),read(args...);
}
template<typename T>inline void prt(T x){
	if(x>9) prt(x/10);
	putchar(x%10+'0');
}
template<typename T>inline void put(T x){
	if(x<0) putchar('-'),x=-x;
	prt(x);
}
template<typename T>inline void put(char ch,T x){
	put(x),putchar(ch);
}
template<typename T,typename ...Args>inline void put(char ch,T x,Args ...args){
	put(ch,x),put(ch,args...);
}
#define N 100005
#define p 998244353
int n,m,dis[N];
vector<int> e[N],g[N];
long long val[N],ans;
int main(){	
	read(n,m);
	for(int i=1;i<=n;i++) read(dis[i]);
	for(int i=1,u,v;i<=m;i++)
		read(u,v),u++,v++,e[u].emplace_back(v),e[v].emplace_back(u);
	for(int i=1;i<=n;i++)
		for(auto v:e[i])
			if(e[i].size()<e[v].size()||(e[i].size()==e[v].size()&&i<v)) 
				g[i].emplace_back(v);
	for(int u=1;u<=n;u++){
		for(auto v:g[u]) val[v]=0;
		for(auto v:g[u])
			for(auto w:g[v]) val[w]+=1ll*dis[u]*dis[v]*dis[w];
		for(auto v:g[u]) ans=(ans+val[v])%p;
	}
	put('\n',ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 8332kb

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: 14ms
memory: 10348kb

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:

-865117687

result:

wrong answer 1st words differ - expected: '397965084', found: '-865117687'