Submission #150897

# Submission time Handle Problem Language Result Execution time Memory
150897 2019-09-01T10:17:26 Z Alexa2001 Bulb Game (FXCUP4_bulb) C++17
100 / 100
103 ms 30364 KB
#include "bulb.h"
#include <bits/stdc++.h>

using namespace std;

const int Nmax = 3e5 + 5;
bool bad = 0;
int v1[Nmax], v2[Nmax];
int subarb[Nmax];

int dfs(int node, vector<int> &L, vector<int> &R, int e1, int e2, int e3)
{
    if(node == -1)
        return 0;

    if(node == -2)
    {
        if(e1 == -1) bad = 1;
        else
            if(e2 == -1) return 1;
                else
                    if(e3 == -1)
                    {
                        v2[e1]++;
                        v2[e2]++;
                    }
        return 0;
    }

    int ans = dfs(L[node], L, R, e1, e2, e3);

    if(e1 == -1) e1 = node;
        else if(e2 == -1) e2 = node;
            else if(e3 == -1) e3 = node;

    ans += dfs(R[node], L, R, e1, e2, e3);

    subarb[node] = ans;
    return ans;
}

int FindWinner(int T, std::vector<int> L, std::vector<int> R)
{
    int n = L.size();
    int e1 = -1, e2 = -1, e3 = -1;

    int total = dfs(0, L, R, e1, e2, e3);

    int i;

    if(bad) return 0;

    for(i=0; i<n; ++i)
    {
        /// E chestii cu un turn, dar nu in subarb lui node

        if(v2[i]) continue;
        if(total - subarb[i]) continue;

        return 1;
    }

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 476 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 476 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 87 ms 7220 KB Output is correct
28 Correct 86 ms 7956 KB Output is correct
29 Correct 89 ms 8352 KB Output is correct
30 Correct 103 ms 30364 KB Output is correct
31 Correct 103 ms 30180 KB Output is correct
32 Correct 87 ms 7084 KB Output is correct
33 Correct 88 ms 8604 KB Output is correct
34 Correct 88 ms 8604 KB Output is correct
35 Correct 89 ms 7132 KB Output is correct
36 Correct 89 ms 7824 KB Output is correct
37 Correct 88 ms 7228 KB Output is correct
38 Correct 89 ms 8616 KB Output is correct
39 Correct 88 ms 8568 KB Output is correct
40 Correct 86 ms 6928 KB Output is correct
41 Correct 87 ms 6776 KB Output is correct
42 Correct 89 ms 8548 KB Output is correct
43 Correct 87 ms 8824 KB Output is correct
44 Correct 87 ms 7804 KB Output is correct
45 Correct 88 ms 7276 KB Output is correct
46 Correct 90 ms 8100 KB Output is correct
47 Correct 90 ms 13080 KB Output is correct
48 Correct 92 ms 13992 KB Output is correct
49 Correct 91 ms 15096 KB Output is correct
50 Correct 92 ms 12564 KB Output is correct