Submission #154294

# Submission time Handle Problem Language Result Execution time Memory
154294 2019-09-20T11:02:10 Z andreiomd Bulb Game (FXCUP4_bulb) C++17
100 / 100
113 ms 10260 KB
#include "bulb.h"
#include <bits/stdc++.h>

using namespace std;

const int NMAX = 3e5 + 5;

vector < int > Left, Right;

int N;

int FindWinner(int T, std :: vector < int > L, std :: vector < int > R)
{
    Left = L;
    Right = R;

    N = (int)L.size();

    int Node = 0;

    while(Node >= 0)
        Node = Left[Node];

    if(Node == -2) /// The leftest bulb is blue;
        return 0;

    for(int i = 0; i < N; ++i)
    {
        bool Red = true;
        bool Ok = false;

        Node = 0;

        while(Node >= 0)
        {
            if(Node == i)
            {
                if(Left[Node] >= 0)
                    Ok = true;
            }
            else
            {
                if(Right[Node] >= 0)
                    Ok = true;
            }

            int Go = (Node == i) ? Left[Node] : Right[Node];

            while(Go >= 0)
                Go = (Go == i) ? Right[Go] : Left[Go];

            if(Go == -2)
            {
                Red = false;

                break;
            }

            if(Node == i) /// The "i" - th swithch is pressed;
                Node = Right[Node];
            else Node = Left[Node];
        }

        if(Red && (!Ok || Node == -1)) /// One red bulb is turned on;
            return 1;
    }

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 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 3 ms 376 KB Output is correct
6 Correct 3 ms 376 KB Output is correct
7 Correct 3 ms 504 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 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 392 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 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 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 504 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 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 360 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 2 ms 376 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 392 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 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 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 504 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 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 360 KB Output is correct
16 Correct 6 ms 376 KB Output is correct
17 Correct 3 ms 376 KB Output is correct
18 Correct 3 ms 376 KB Output is correct
19 Correct 2 ms 376 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 74 ms 10156 KB Output is correct
28 Correct 74 ms 10232 KB Output is correct
29 Correct 86 ms 10232 KB Output is correct
30 Correct 79 ms 10232 KB Output is correct
31 Correct 77 ms 10156 KB Output is correct
32 Correct 87 ms 10232 KB Output is correct
33 Correct 74 ms 10204 KB Output is correct
34 Correct 103 ms 10204 KB Output is correct
35 Correct 81 ms 10108 KB Output is correct
36 Correct 113 ms 10232 KB Output is correct
37 Correct 87 ms 10124 KB Output is correct
38 Correct 106 ms 10232 KB Output is correct
39 Correct 78 ms 10232 KB Output is correct
40 Correct 78 ms 10232 KB Output is correct
41 Correct 109 ms 10260 KB Output is correct
42 Correct 97 ms 10244 KB Output is correct
43 Correct 106 ms 10232 KB Output is correct
44 Correct 112 ms 10232 KB Output is correct
45 Correct 105 ms 10128 KB Output is correct
46 Correct 81 ms 10232 KB Output is correct
47 Correct 77 ms 10232 KB Output is correct
48 Correct 82 ms 10232 KB Output is correct
49 Correct 76 ms 10208 KB Output is correct
50 Correct 77 ms 10104 KB Output is correct