답안 #154295

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
154295 2019-09-20T11:05:28 Z andreiomd Bulb Game (FXCUP4_bulb) C++17
100 / 100
109 ms 7800 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; /// Daca alegem apasarea unui intrerupator, iar in partea dreapta, exista subarbore;

        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 switch is pressed;
                Node = Right[Node];
            else Node = Left[Node];
        }

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

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 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 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 348 KB Output is correct
10 Correct 1 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 0 ms 248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 3 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 376 KB Output is correct
8 Correct 3 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 348 KB Output is correct
12 Correct 1 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 0 ms 248 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 3 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 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 400 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 3 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 376 KB Output is correct
8 Correct 3 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 348 KB Output is correct
12 Correct 1 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 0 ms 248 KB Output is correct
15 Correct 6 ms 376 KB Output is correct
16 Correct 3 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 3 ms 376 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 376 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 400 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 73 ms 7448 KB Output is correct
28 Correct 73 ms 7416 KB Output is correct
29 Correct 87 ms 7544 KB Output is correct
30 Correct 76 ms 7544 KB Output is correct
31 Correct 77 ms 7580 KB Output is correct
32 Correct 86 ms 7480 KB Output is correct
33 Correct 79 ms 7544 KB Output is correct
34 Correct 109 ms 7580 KB Output is correct
35 Correct 84 ms 7420 KB Output is correct
36 Correct 102 ms 7452 KB Output is correct
37 Correct 60 ms 7544 KB Output is correct
38 Correct 98 ms 7552 KB Output is correct
39 Correct 75 ms 7544 KB Output is correct
40 Correct 74 ms 7488 KB Output is correct
41 Correct 96 ms 7544 KB Output is correct
42 Correct 94 ms 7576 KB Output is correct
43 Correct 103 ms 7760 KB Output is correct
44 Correct 94 ms 7544 KB Output is correct
45 Correct 101 ms 7612 KB Output is correct
46 Correct 77 ms 7616 KB Output is correct
47 Correct 74 ms 7544 KB Output is correct
48 Correct 84 ms 7544 KB Output is correct
49 Correct 81 ms 7800 KB Output is correct
50 Correct 78 ms 7560 KB Output is correct