QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#711933#7986. 游戏sdmrlh#WA 14ms14116kbC++141.0kb2024-11-05 14:01:402024-11-05 14:01:45

Judging History

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

  • [2024-11-05 14:01:45]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:14116kb
  • [2024-11-05 14:01:40]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld%lld",&x,&y)
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pf(x) printf("%lld",x)
#define pii pair<int,int> 
#define f first 
#define s second
#define int long long



//
//
const int N = 1e6+10;
int h[N],e[N],ne[N],idx,du[N];
void add(int a,int b)
{
	ne[idx]=h[a],e[idx]=b,h[a]=idx++;
}

bool dfs(int u,int fa,int d)
{
	int sum=0;
	if(du[u]==2&&u!=1) return 0;
	for(int i=h[u];~i;i=ne[i])
	{
		int j=e[i];
		if(j==fa) continue;
		if(dfs(j,u,d+1)) sum++;
	}
	if(sum>=2||!sum) return 1;
	return 0;
}
//



void solve()
{
	int m,n;
	cin>>m;
	n=m-1;
	for(int i=1;i<=m;i++) h[i]=-1;
	while(n--)
	{
		int a,b;
		cin>>a>>b;
		add(a,b);
		add(b,a);
		du[a]++,du[b]++;
	}

	if(dfs(1,-1,0)&&du[1]>=2)cout<<"You win, temporarily."<<endl;
	else cout<<"Wasted."<<endl;
}
signed main()
{
	IOS;
	int _=1;
	while(_--)
		solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6
1 2
2 3
2 4
1 5
5 6

output:

Wasted.

result:

ok single line: 'Wasted.'

Test #2:

score: 0
Accepted
time: 1ms
memory: 7628kb

input:

7
1 2
2 3
2 4
1 5
5 6
5 7

output:

You win, temporarily.

result:

ok single line: 'You win, temporarily.'

Test #3:

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

input:

1

output:

Wasted.

result:

ok single line: 'Wasted.'

Test #4:

score: 0
Accepted
time: 14ms
memory: 12888kb

input:

100000
86389 1
68115 86389
27661 68115
9669 27661
7343 9669
59420 7343
98078 59420
39321 98078
14847 39321
76863 14847
21104 14847
24241 39321
82708 39321
73282 82708
7424 39321
64358 7424
81481 39321
17105 81481
74205 17105
81202 98078
63636 81202
62429 63636
85827 62429
8648 62429
67963 63636
7287...

output:

You win, temporarily.

result:

ok single line: 'You win, temporarily.'

Test #5:

score: -100
Wrong Answer
time: 14ms
memory: 14116kb

input:

100000
28424 1
91124 28424
70268 91124
99456 70268
80696 99456
72802 80696
69700 72802
77527 72802
3835 80696
83715 3835
6690 3835
63240 3835
87789 80696
29903 99456
21234 29903
92544 21234
87569 21234
67361 29903
18146 67361
22916 67361
7024 99456
62805 7024
24624 7024
37895 7024
29126 99456
13746 ...

output:

You win, temporarily.

result:

wrong answer 1st lines differ - expected: 'Wasted.', found: 'You win, temporarily.'