QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#741118#7986. 游戏_LSA_#WA 1ms5976kbC++14959b2024-11-13 13:24:402024-11-13 13:24:41

Judging History

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

  • [2024-11-13 13:24:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5976kb
  • [2024-11-13 13:24:40]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define fi first
#define se second
#define mk make_pair
using namespace std;
ll read(){
    ll X = 0 ,r = 1;
    char ch = getchar();
    while(!isdigit(ch) && ch != '-') ch = getchar();
    if(ch == '-') r = -1,ch = getchar();
    while(isdigit(ch)) X = X*10+ch-'0',ch = getchar();
    return X*r;
}
const int N = 1e5+10;
int n,f[N];
vector<int> G[N];
void dfs(int x,int fa){
    if(G[x].size() == 1 && x != 1) f[x] = 2;
    else{
        for(int y : G[x]){
            if(y == fa) continue;
            dfs(y,x);
            if(f[y] >= 2) f[x]++;
        }    
    }
}
int main(){
    n = read();
    for(int i=2;i<=n;i++){
        int u = read(),v = read();
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1,0);
    puts((f[1] >= 2 || n == 1) ? "You win, temporarily." : "Wasted.");
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0ms
memory: 5976kb

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

input:

1

output:

You win, temporarily.

result:

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