QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#731296#2376. Game on a TreeLaVuna47WA 1ms3728kbC++201.4kb2024-11-10 01:50:312024-11-10 01:50:32

Judging History

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

  • [2024-11-10 01:50:32]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3728kb
  • [2024-11-10 01:50:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define x first
#define y second
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef double db;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;

#ifdef ONPC
mt19937 rnd(228);
#endif

const int N = 1e5 + 47;
vector<int> g[N];
int dp[N];

void dfs(int v, int p)
{
	int sm = 0;
	for (int to: g[v])
	{
		if (to != p)
			dfs(to, v);
		sm += dp[to];
	}
	if (sm == 0)
		dp[v] = 1;
	else
		dp[v] = sm - 1;
}

int solve()
{
	int n;
	if (!(cin >> n))
		return 1;
		
	fill(g, g + n, vector<int>());
	fill(dp, dp + n, 0);
	FOR (i, 0, n - 1)
	{
		int v, u;
		cin >> v >> u;
		--v;--u;
		g[v].pb(u);
		g[u].pb(v);
	}
	dfs(0, -1);
	if (dp[0])
		cout << "Bob\n";
	else
		cout << "Alice\n";
		
	return 0;
}

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int TET = 1e9;
	//cin >> TET;
	for (int i = 1; i <= TET; i++)
	{
		if (solve())
			break;
			
		#ifdef ONPC
			cerr << "_____________________________\n";
		#endif
	}
	#ifdef ONPC
		cerr << "\nfinished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec\n";
	#endif
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3728kb

input:

4
1 2
2 3
3 4

output:

Alice

result:

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