QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#410142#7986. 游戏Liangsheng298WA 68ms6916kbC++141.3kb2024-05-13 16:07:382024-05-13 16:07:39

Judging History

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

  • [2024-05-13 16:07:39]
  • 评测
  • 测评结果:WA
  • 用时:68ms
  • 内存:6916kb
  • [2024-05-13 16:07:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T read(){
    T x=0;char ch=getchar();bool fl=false;
    while(!isdigit(ch)){if(ch=='-')fl=true;ch=getchar();}
    while(isdigit(ch)){x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return fl?-x:x;
}
#define LL long long 
#define read() read<int>()
const int maxn = 1e5 + 10;
int head[maxn],cnt=0;
struct edge{
    int to,nxt;
}e[maxn<<1];
inline void link(int u,int v){
    e[++cnt].to=v;e[cnt].nxt=head[u];head[u]=cnt;
}
int deg[maxn],n,sz[maxn],son[maxn],son1[maxn];
void dfs(int u,int fa){
    if(deg[u]==1 && u!=1)sz[u]=1;
    for(int i=head[u];i;i=e[i].nxt){
        int v=e[i].to;
        if(v==fa)continue;
        dfs(v,u);
        sz[u]+=sz[v];
        if(sz[son[u]]<=sz[v])son1[u]=son[u],son[u]=v;
    }
}
inline bool solve(){
    if(!son[1])return false;
    if(son[1] && !son1[1])return true;
    int u=1;
    while(1){
        if(deg[u]==1)return true;
        if(!son1[u])return false;
        u=son1[u];
    }
}
int main(){
    n=read();
    for(int i=1;i<n;i++){
        int u=read(),v=read();
        link(u,v);link(v,u);
        deg[u]++;deg[v]++;
    }
    dfs(1,0);
    for(int i=1;i<=n;i++)cerr<<son[i]<<" "<<son1[i]<<endl;//
    bool fl=solve();
    puts(fl?"You win, temporarily.":"Wasted.");
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5620kb

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: 3532kb

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: 1ms
memory: 5616kb

input:

1

output:

Wasted.

result:

ok single line: 'Wasted.'

Test #4:

score: -100
Wrong Answer
time: 68ms
memory: 6916kb

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:

Wasted.

result:

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