QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#182050#6858. Play on TreemasterhuangWA 126ms19752kbC++20850b2023-09-17 10:19:312023-09-17 10:19:31

Judging History

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

  • [2023-09-17 10:19:31]
  • 评测
  • 测评结果:WA
  • 用时:126ms
  • 内存:19752kb
  • [2023-09-17 10:19:31]
  • 提交

answer

#include<bits/stdc++.h>
#define LL long long
#define fr(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
const int N=2e5+5,mod=1e9+7;
int T,n;LL f[N];
vector<int>g[N];
inline int ksm(int x,int p){int s=1;for(;p;(p&1)&&(s=1ll*s*x%mod),x=1ll*x*x%mod,p>>=1);return s;}
void dfs(int x,int fa){for(int i:g[x]) if(i^fa) dfs(i,x),f[x]^=(f[i]+1);}
void dfs1(int x,int fa)
{
	if(fa) f[x]^=(f[fa]^(f[x]+1)+1);
	for(int i:g[x]) if(i^fa) dfs1(i,x);
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin>>T;
	while(T--)
	{
		cin>>n;int ans=0;memset(f,0,sizeof(f));
		for(int i=1,u,v;i<n;i++) cin>>u>>v,g[u].push_back(v),g[v].push_back(u);
		dfs(1,0);dfs1(1,0);for(int i=1;i<=n;i++) ans+=(f[i]>0);
		cout<<(1ll*ans*ksm(n,mod-2)%mod)<<"\n";
		for(int i=1;i<=n;i++) g[i].clear();
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 126ms
memory: 19752kb

input:

3
199999
144802 35753
35753 9646
9646 148183
9646 167003
9646 199831
9646 193968
9646 182279
9646 185547
9646 106896
9646 196577
9646 150627
9646 147736
9646 180949
9646 179482
9646 196999
9646 191636
9646 184859
9646 173080
9646 155500
9646 191682
9646 169619
9646 191285
9646 106525
9646 187324
964...

output:

221491110
765128832
152099157

result:

wrong answer 1st lines differ - expected: '256641286', found: '221491110'