QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#377404#7986. 游戏Only#WA 165ms21164kbC++171.8kb2024-04-05 13:13:062024-04-05 13:13:06

Judging History

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

  • [2024-04-05 13:13:06]
  • 评测
  • 测评结果:WA
  • 用时:165ms
  • 内存:21164kb
  • [2024-04-05 13:13:06]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define PII pair<ll, ll>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define of(i, l, r) for (int i = l; i >= r; i--)
#define mem(a, b) memset(a, b, sizeof(a))
#define F first
#define S second
const double pi = acos(-1.0);
const ll LNF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MOD = 998244353;
const ll mod = 1e9+7;
const int N = 1e5+50;
const int M = 1e5+50;
const int MAXN=150;

map<ll, ll> mp, sb;
vector<ll> a[N];
int vis[N];
ll n;

void dfs(ll p)
{
    vis[p] = 1;
    if(a[p].size()==1)
    {
        return;
    }
    for(auto i:a[p])
    {
        if(!vis[i])
        {
            sb[i] = p;
            dfs(i);
        }
    }
    return;
}

void Solve()
{
    cin >> n;
    fo(i, 1, n-1)
    {
        ll l, r;
        cin >> l >> r;
        a[l].push_back(r);
        a[r].push_back(l);
    }
    if(n==2)
    {
        cout << "You win, temporarily." << '\n';
        return;
    }
    dfs(1);
    fo(i, 2, n)
    {
        if(a[i].size()==1)
        {
            ll hh=sb[i];
            mp[i] = 1;
            while(hh!=1)
            {
                if(a[hh].size()-1==1)
                {
                    break;
                }
                mp[hh] = 1;
                hh = sb[hh];
            }
        }
    }
    for(auto i:a[1])
    {
        mp[1] += mp[i];
    }
    // cout << mp[1] << '\n';
    if(mp[1]>=2 || n==2)
    {
        cout << "You win, temporarily." << '\n';
    }
    else
    {
        cout << "Wasted." << '\n';
    }
	return;
}

int main(void)
{
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int t=1;
	// cin >> t;
	while(t--)
	{
		Solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 5908kb

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: 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: 0
Accepted
time: 0ms
memory: 6008kb

input:

1

output:

Wasted.

result:

ok single line: 'Wasted.'

Test #4:

score: 0
Accepted
time: 165ms
memory: 21164kb

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: 93ms
memory: 20356kb

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