QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#679385#7786. Graft and Transplantsurenjamts#WA 0ms3692kbC++17691b2024-10-26 17:30:232024-10-26 17:30:24

Judging History

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

  • [2024-10-26 17:30:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3692kb
  • [2024-10-26 17:30:23]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
vector<int> adj[505];
int depth[505];
void dfs(int node, int pre, int d){
	depth[node]=d;
	for(int i: adj[node]){
		if(i!=pre){
			dfs(i,node,d+1);
		}
	}
}
signed main(){
	int n;
	cin>>n;
	for(int i=0; i<n-1; i++){
		int u,v;
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	for(int i=1; i<=n; i++){
		for(int j=0; j<=100; j++){
			depth[i]=0;
		}
		dfs(i,0,0);
		int cnt=0;
		for(int j=1; j<=n; j++){
			if(depth[j]>=2) cnt++;
		}
		if(cnt%2==1){
			cout<<"Alice"<<endl;
			return 0;
		}
	}
	cout<<"Bob"<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4
1 2
2 3
3 4

output:

Alice

result:

ok "Alice"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

4
1 2
1 3
1 4

output:

Bob

result:

ok "Bob"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3552kb

input:

2
1 2

output:

Bob

result:

ok "Bob"

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3556kb

input:

3
1 2
1 3

output:

Alice

result:

wrong answer 1st words differ - expected: 'Bob', found: 'Alice'