QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#318580 | #7986. 游戏 | tarjen | WA | 1ms | 3616kb | C++20 | 619b | 2024-01-31 15:31:26 | 2024-01-31 15:31:27 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5+7;
vector<int> G[maxn];
bool ok[maxn];
void dfs(int u,int fa=-1)
{
if(G[u].size()==1&&G[u][0]==fa)
ok[u]=1;
int cnt=0;
for(auto v:G[u])
{
if(v!=fa)
{
dfs(v,u);
cnt+=ok[v];
}
}
if(cnt>=2) ok[u]=1;
}
int main()
{
int n;
cin>>n;
for(int i=1,u,v;i<n;i++)
{
cin>>u>>v;
G[u].push_back(v);
G[v].push_back(u);
}
dfs(1);
if(ok[1]||n==1) cout<<"You win, temporarily.\n";
else cout<<"Wasted.";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3572kb
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: 3616kb
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: -100
Wrong Answer
time: 1ms
memory: 3588kb
input:
1
output:
You win, temporarily.
result:
wrong answer 1st lines differ - expected: 'Wasted.', found: 'You win, temporarily.'