Submission #149469

# Submission time Handle Problem Language Result Execution time Memory
149469 2019-09-01T06:33:31 Z mit한의대지망생(#3602, TAMREF, imeimi2000, suzy) Bulb Game (FXCUP4_bulb) C++17
0 / 100
11 ms 376 KB
#include "bulb.h"
#include <vector>

using namespace std;

vector<int> L, R;

int n;
bool vis[300001];
bool chB[300001];
bool res[300001];

void dfs(int x) {
    if (vis[x]) return;
    vis[x] = 1;
    if (L[x] < 0) {
        res[x] = L[x] == -2;
    }
    else {
        dfs(L[x]);
        res[x] = res[L[x]];
    }
    if (R[x] < 0) {
        chB[x] = R[x] == -2;
    }
    else {
        dfs(R[x]);
        chB[x] = res[R[x]];
    }
}

int FindWinner(int T, vector<int> _L, vector<int> _R) {
    n = _L.size();
    L = _L;
    R = _R;
    for (int x = 0; x < n; ++x) {
        swap(L[x], R[x]);
        for (int i = 0; i < n; ++i) {
            vis[i] = 0;
        }
        dfs(0);
        int i;
        for (i = 0; i < n; ++i) {
            if (chB[i]) break;
        }
        if (i == n) return 1;
        swap(L[x], R[x]);
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 376 KB Output is correct
2 Incorrect 11 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Incorrect 11 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 10 ms 376 KB Output is correct
4 Incorrect 11 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -