QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#318580#7986. 游戏tarjenWA 1ms3616kbC++20619b2024-01-31 15:31:262024-01-31 15:31:27

Judging History

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

  • [2024-01-31 15:31:27]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3616kb
  • [2024-01-31 15:31:26]
  • 提交

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.'